How do I update new instances launched by AWS autoscaling?

We use AWS Cloud Information Service to initialize our stack and configure autoscaling service to create new application servers as load increases.

I understand that Auto Scaling can only launch predefined AMIs as new instances. These instances may differ from other running instances as packages / source code may be updated in those instances.

How can I update new instances? Do I have to update the AMI every time I deploy something new to the executable instances? Or is there a way to run automatic deployment to new instances (Opsworks) while autoscaling?

I'm new to AWS so forgive me if my question is a rudimentary one.

+3


source to share


2 answers


There are several ways to do this. My preferred approach is to never touch the servers directly, but instead create a new AMI whenever I deploy a new version of the software.

To do this, use the property AutoScalingRollingUpdate

for the autoscale group. When you then change ImageId

for launch configuration, AWS will automatically replace the old servers with the new ones as a rolling upgrade.



I have a simple deployment script that creates a new AMI, replaces ImageId

in the template, and then updates the stack - AWS takes care of the rest.

+7


source


When EC2 is instantiated from Beanstalk, it automatically creates an AutoScaling and Launch Configuration group based on the environment settings you specify. Instantiation from the underlying AMI is done with a custom code call to custom data , which includes a wrapper script to create folders and install the appropriate software.

You can add new scripts or shell commands to do your custom work before starting a new instance. This way it is much easier. for example you can run yum update before running instance



To find the user data section Go to the EC2 console -> Go to the launch configuration section (left) -> Select the correct launch configuration and copy it -> Click the user data view -> Add your scripts and commands as needed -> Change the appropriate autoscale group to point to new launch configuration

+5


source







All Articles