This guide shows how to set up autoscaling EC2 instances with a startup script using User Data.

How does EC2 User Data work?

User Data allows you to specify a startup script or startup data that will run when a new EC2 instance is created. When used in AutoScaling this means that when AutoScaling automatically creates a new EC2 instance for you from a pre-set AMI, then the user data startup script will run automatically for you.

One common use of user data is to set up a new EC2 instance with the latest code base. For example, when a new instance loads your startup script can call your source code repository, grab the latest source code, and set it up.

More Info

User Data can be set up on Linux and Windows AMI/EC2 instances. You can set up a script to run on startup, or you can pass data to the new EC2 instance.
Here are a few useful links:
  1. Amazon Documentation
  2. Amazon Forum Question for Windows AMIs
  3. How to read the data for Linux
  4. More info on Linux AMIs

Create an AutoScaling Environment with User Data

  1. Log into EZAutoScaling

  2. Click on the Launch Configs menu
    Create Launch Configuration
  3. Create a new Launch Configuration. Make sure you use an AMI that allows User Data. Choose AMI
  4. In the User Data field either upload a file with your script or type what you would like the new EC2 instance to execute on start up. For example, for Windows AMIs you can type inside <script> tags, for example:
    ipconfig /all > c:\ipconfig.txt
    netstat > c:\netstat.txt
    Please follow the links above to see what else you can do with this field.
    Enter EC2 User-Data
  5. Create an Auto Scaling Group with this Launch Configuration. Every EC2 instance that spawns in that Auto Scaling Group will use the User Data that you provided. AutoScaling with User-Data

Sign Up

Back to How To Guides

comments powered by Disqus

Back to top

Copyright © EZAutoScaling Inc. About · Contact · Privacy · Terms

"Amazon Web Services", "AWS", "Auto Scaling", "EC2", "CloudWatch" are trademarks of, Inc.