gsandie online notebook

Execute user data in AWS

Using the ubuntu ec2 images from canonical you can have user data execute as a script. Simply start the data with a #!. If you want to log what happens you can log to a file at the start of your script.

E.g

#!/bin/bash
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
apt-get update
apt-get -y install build-essential

Or can go to syslog with the appropriate logger command.

References:

http://alestic.com/2009/06/ec2-user-data-scriptshttp://cloud.ubuntu.com/2010/12/logging-user-data-script-output-on-ec2-instances/