amazon web services - How to create a LaunchConfiguration using CloudFormation template which creates a config file? -


i want write launchconfiguration aws stack using cloudformation template. have written below.

"launchconfiguration": {   "type": "aws::autoscaling::launchconfiguration",   "metadata" : {       "aws::cloudformation::init" : {           "files": {               "/etc/test.conf": {                   "content": { "fn::join": [ "", [                                                   "user: root\n",                                                   "password: password\n"                   ]]},                   "mode": "000400",                   "user": "root",                   "group": "root"               }           }       }   },   "properties": {     "imageid": "ami-*****",     "instancetype": "*****",     "keyname": "*****",     "iaminstanceprofile": "*****",     "instancemonitoring": "****",     "securitygroups": [       {         "ref": "securitygroup"       }     ]   } }, 

the file not being created in ec2 instances created. can me on this?

you're missing couple things. first, need invoke cfn-init script launchconfiguration userdata. http://docs.aws.amazon.com/awscloudformation/latest/userguide/cfn-helper-scripts-reference.html

"userdata" : { "fn::base64" : { "fn::join" : [ "", [   "#!/bin/bash -ve\n",    "# run cfn-init\n",   "/opt/aws/bin/cfn-init -v ",   "         --stack ", { "ref": "aws::stackname" },   "         --resource launchconfiguration ",   "         --region ", { "ref" : "aws::region" }, "\n",    "# signal success\n",   "/opt/aws/bin/cfn-signal -e $? ",   "         --stack ", { "ref" : "aws::stackname" },   "         --resource autoscalinggroup ",   "         --region ", { "ref" : "aws::region" }, "\n" ]]}} 

this example uses cfn-signal signal success notifies auto scaling group instance bootstrapping successful. use feature, need add creationpolicy autoscalinggroup resource. http://docs.aws.amazon.com/awscloudformation/latest/userguide/aws-attribute-creationpolicy.html

  "creationpolicy" : {     "resourcesignal" : {       "timeout" : "pt10m",       "count"   : "1"     }   } 

lastly, missing default config wrapper around metadata.

  "metadata" : {     "aws::cloudformation::init" : {       "config" : {         "files": {           "/etc/test.conf" : {             "content" : { "fn::join": [ "", [               "user: root\n",               "password: password\n"             ]]},             "mode" : "000400",             "user" : "root",             "group" : "root"           }         }       }     }   } 

you can use other config, need define configsets attribute. http://docs.aws.amazon.com/awscloudformation/latest/userguide/aws-resource-init.html#aws-resource-init-configsets

"aws::cloudformation::init" : {   "configsets" : {       "default" : [         "db-config",         "app-config"       ]   },   "db-config": {     "files": {       ...     }   },   "app-config": {     ...   } } 

for more information, detailed overview of bootstrapping instances using cloudformation. https://s3.amazonaws.com/cloudformation-examples/boostrappingapplicationswithawscloudformation.pdf


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -