Up until now I've been launching EC2 instances manually, copying over a bash script that downloads my chef + chef artifacts, and calls chef-solo to provision an instance.

A former AWS engineer in the company had at one point created CF templates; which I barely know how to use.

Is there a way to integrate my bash script into the CF template, so that upon CF EC2 instance launch, my bash script is called and the instance is auto-provisioned?

1 Answer 1


Yes, you can use the UserData attribute of your AWS::EC2::Instance object.


This attribute takes as input the base64-encoded version of your shell script. You can, however, provide the script inline with the help of a Cloudformation Base64 function:

"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
    "#!/bin/bash -v\n",
    "# Script goes here\n"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.