Create an RDS Opsworks Layer by a Cloudformation template

265 views Asked by At

I'm making a CloudFormation template that creates an opsworks stack, layers and few applications. Within my layers, I have opsworks ones and RDS ones. In the AWS documentation, there is only how to create Opsworks::Layer but I don't know how to make an Amazon RDS service layer:

enter image description here

{
  "Type": "AWS::OpsWorks::Layer",
  "Properties": {
    "Attributes" : { String:String },
    "AutoAssignElasticIps" : Boolean,
    "AutoAssignPublicIps" : Boolean,
    "CustomInstanceProfileArn" : String,
    "CustomJson" : JSON object,
    "CustomRecipes" : Recipes,
    "CustomSecurityGroupIds" :  [ String, ... ],
    "EnableAutoHealing" : Boolean,
    "InstallUpdatesOnBoot" : Boolean,
    "LifecycleEventConfiguration" : LifeCycleEventConfiguration,
    "LoadBasedAutoScaling" : LoadBasedAutoScaling,
    "Name" : String,
    "Packages" : [ String, ... ],
    "Shortname" : String,
    "StackId" : String,
    "Type" : String,
    "VolumeConfigurations" : [ VolumeConfiguration, ... ]
  }
}

My aim is to automate the creation of my opsworks resources by cloudformation. Any idea how to do this ? Thank you

2

There are 2 answers

0
collins lidédé On

Learning more on cfn-init would be my best bet. Hope this helps you out

1
wjordan On

Unfortunately, according to Richard@AWS as of Dec 9 2015, the RegisterRdsDbInstance API which registers an RDS instance as an OpsWorks service layer is not implemented through an official CloudFormation resource, and there are no scheduled plans to do so.

You can contact AWS to request adding this to their roadmap, but in the meantime here are some alternatives you can try:

  1. Create your RDS instance and the rest of your OpsWorks stack from a CloudFormation template, then manually attach the RDS service layer to the OpsWorks stack using the AWS Console, AWS CLI, or any another platform's AWS SDK.
  2. Use a self-managed database instance layer running on an EC2 instance using an AWS::OpsWorks::Layer with a Type of db-master, as described in the AWS OpsWorks Template Snippet.
  3. Create a Custom CloudFormation Resource that performs the RegisterRdsDbInstance API call, e.g., using a Lambda function and the NodeJS AWS SDK.