Skip to content

Instantly share code, notes, and snippets.

@chhibber
Last active June 23, 2022 20:02
Show Gist options
  • Save chhibber/6908927 to your computer and use it in GitHub Desktop.
Save chhibber/6908927 to your computer and use it in GitHub Desktop.
LaunchConfig with Cloudformation::Init
"LaunchConfig" : {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config" : {
"files" : {
"/tmp/boot-strap-nat00.sh" : {
"source" : { "Fn::Join" : ["", [
"http://", { "Ref" : "AWS::Region" }, "-development-appname", ".s3.amazonaws.com/path/to/boot-strap-nat00.sh"
]]}
}
}
}
},
"AWS::CloudFormation::Authentication": {
"rolebased" : {
"type": "s3",
"buckets": [ { "Fn::Join" : ["", [ { "Ref" : "AWS::Region" }, "-development-appname" ]]} ],
"roleName": { "Ref" : "IAMNATROLE" }
}
}
},
"Properties" : {
"AssociatePublicIpAddress" : "True",
"KeyName" : { "Fn::Join" : [ "", [ { "Ref" : "AWS::Region" }, "-development" ] ] },
"ImageId" : { "Fn::FindInMap" : [ "RegionMapNat", { "Ref" : "AWS::Region" }, "AMI"]},
"IamInstanceProfile": { "Ref" : "IAMNATROLE" },
"SecurityGroups" : [ { "Ref" : "SGnat" } ],
"InstanceType" : "m1.small",
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash\n",
"set -e\n",
"set -x\n",
"yum -y update\n",
"sleep 3\n",
"yum -y update\n",
"easy_install --upgrade boto\n",
"# Download our bootstrap file\n",
"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackId" }, " -r LaunchConfig ",
" --region ", { "Ref" : "AWS::Region" }, " || error_exit 'Failed to run cfn-init'\n",
"chmod u+x /tmp/boot-strap-nat00.sh\n",
"/tmp/boot-strap-nat00.sh\n"
]]}}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment