Skip to content

Instantly share code, notes, and snippets.

@mohanpedala
Last active June 6, 2017 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohanpedala/28d743b8ac3b8b191660275bac281c08 to your computer and use it in GitHub Desktop.
Save mohanpedala/28d743b8ac3b8b191660275bac281c08 to your computer and use it in GitHub Desktop.
Using userdata to bootstrap an EC2 Instance

Using userdata to bootstrap an EC2 Instance

It is possible to bootstrap an EC2 instance by running a shell script on launch. The shell script that you want to run when a new EC2 instance is created should be placed in the userdata section. Userdata section can be found in the advanced options while configuring the new EC2 instance. The userdata that is provided on EC2 creation console is copied to the below mentioned folder

/var/lib/cloud/instance/scripts

Also, the log file for the userdata execution can be found here :

/var/log/cloud-init.log

Please note that the you might have to wait for a while for the userdata to completely finish executing. The wait time depends on the userdata that you provide. After logging in to the EC2 instance, you can verify the status of the userdata execution by tailing the log file mentioned above using the below command.

tail -f /var/log/cloud-init.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment