Here's a whitepaper to get you started with Integrating AWS CloudFormation with Opscode Chef.
I've uploaded some templates based on the sample templates provided, and am noting my customisations.
This is pretty straightforward. My only change is in the AWS::EC2::Instance Metadata where I've given a role and tagged this instance with the Stackname.
"/etc/chef/roles.json" : {
"content" : {
"run_list": [ "role[rabbitmq]" ],
"tags": { "Ref": "AWS::StackName" }
},
An autoscaling group is quite similar, except the Userdata which performs the bootstrapping is located in the AWS::AutoScaling::LaunchConfiguration section.
"LaunchConfig" : {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Properties" : {
"UserData" : { "Fn::Base64" : { "Ref" : "WebServerPort" }},
This is pretty amazing. You can use CFN templates to create CFN stacks, and pass parameters to the child stacks. This is like Lego blocks for your infrastructure, which combined with Chef seems infinitely great. The only drawback is currently CFN does everything sequentially, so I tend not to use this feature and create my stacks in parallel.
"Resources" : {
"RabbitMQ": {
"Type" : "AWS::CloudFormation::Stack",
"Properties" : {
"TemplateURL" : "https://s3.amazonaws.com/<bucket>/<template>.json",
"KeyName" : { "Ref" : "KeyName" },
"InstanceType" : { "Ref" : "InstanceType"},
"EC2SecurityGroup" : { "Ref" : "EC2SecurityGroup" },
"ChefClientUser" : { "Ref" : "ChefClientUser" },
"HostKeys" : { "Ref" : "HostKeys" },
"BucketPolicy" : { "Ref" : "BucketPolicy" }
}
}