Currently we are using Serverless framework to update our dev/test environments, and manage our environments manually. Eg. each time we create a new environment, we manually create Elastic Beanstalk application & RDS instance. Is it possible to automate all this using serverless script? or cloudformation?
With CloudFormation that's pretty straight forward. All you need is to define an AWS::RDS::DBInstance
. AWS also provides some example templates for that: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/sample-templates-services-us-east-1.html#w2ab2c23c42c13c27
As you can include CloudFormation resources in Serverless, you can add that directly to your serverless.yml
so it gets deployed by Serverless without the need to use a separate CloudFormation deployment: https://serverless.com/framework/docs/providers/aws/guide/resources/
More complete example of all available options for RDS (including Aurora): https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbcluster.html
Yes you can definitely create your rds instances with cloudformation templates,
"MyDB" : {
"Type" : "AWS::RDS::DBInstance",
"Properties" : {
"DBSecurityGroups" : [
{"Ref" : "MyDbSecurityByEC2SecurityGroup"}, {"Ref" : "MyDbSecurityByCIDRIPGroup"} ],
"AllocatedStorage" : "5",
"DBInstanceClass" : "db.m1.small",
"Engine" : "MySQL",
"MasterUsername" : "MyName",
"MasterUserPassword" : "MyPassword"
},
"DeletionPolicy" : "Snapshot"
}
This json snippet will create your RDS instance, for complete reference to create your RDS and Elastic beanstalk refer :
https://github.com/satterly/AWSCloudFormation-samples/blob/master/ElasticBeanstalk.template
Hope it will help !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With