What's in your userdata.sh?

Do most folks use a userdata.sh script when they spawn a new instance, and if so what’s in yours?


Related discussions:

Mine usually consist of something like a line to install Chef and another one loading a cookbook bundle directly from S3 and executing recipes :slight_smile:

I use auto scaling groups. My userdata is a script that configures the EC2 Container Service agent and downloads/starts Consul agent and Registrator. I also set the hostname of the machine to something slightly more helpful than ip-XXX-XXX-XXX-XXX.

FWIW, my image has already been set up using Chef, or else I’d do that too. I would just rather have one image that’s already good to go than an instance that takes 5 minutes to boot.

Do you use a chef server or chef-solo? how do you do auth if you’re using chef server?

I use chef-zero because I only use Chef during the image building process and on boot (where all I’m doing is setting the hostname). As such, I just use Packer and drop all the Chef stuff on the box and then run chef-zero. The downside is that a cookbook change requires a new image, but we replace images frequently. This strategy means that if we find a problem with a new image (be it Chef related, OS related, or whatever) we can revert to the old image and be guaranteed that it will work exactly as before.

We just have a script that downloads SSH public keys and puts them in the appropriate spots so we can SSH in after. That way we don’t need to use some shared root private key.

Latest, enable EC2Config CloudWatch logs on Windows systems. Pick up the configuration JSON from s3. Soon to be replaced by SSM

Yum updates, ssh keys, tmp mapping to ephemeral storage, codedeploy agent installation, cloudwatch custom monitor installation, and software prerequisite bundle.