Search code examples
amazon-web-servicesamazon-ec2aws-auto-scaling

How can I run User Data on more than one instance?


So I know I can go into the AWS console and one by one edit the user-data, but I want to run the same user-data on all instances in the same auto scaling group. Is this possible?


Solution

  • When you launch an autoscaling group you have the choice over using a launch template or a launch configuration which defines the settings for the instances that are launched (such as instance class, AMI to use etc).

    IF you're using a launch template you can create a new version, by doing this you can update the parameters (including the User Data found under the Advanced section). Alternatively you can create a new template and fill it out with the parameters as required.

    If you're using a launch configuration you will need to create a new launch configuration as it does not support versioning. During the "Configure details" stage of the wizard you will be provided with a textarea to specify your user data as you would for a standard EC2.

    Once you have made one of the changes above you will need to update your autoscaling group to use these changes. Additionally you will need to terminate any old instances, to allow newer instances to replace them with the new user data.