Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can serverless be used to to create RDS instance?

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?

like image 443
Veer3383 Avatar asked Sep 05 '17 05:09

Veer3383


2 Answers

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

like image 194
Dunedan Avatar answered Oct 19 '22 15:10

Dunedan


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 !

like image 30
Shashi Bhushan Avatar answered Oct 19 '22 16:10

Shashi Bhushan