How do I update new instances started by AWS auto scaling?
Asked Answered
C

2

8

We use AWS cloudformation service to initialize our stack, and set up the auto scaling service to bring up new app servers when load is rising.

My understanding is that Auto Scaling can only start predefined AMI as new instances. These instances could be different from other running instances, because we may have updated packages/source code deployed on those instances.

How can I bring the new instances up-to-date? Should I update the AMIs everytime I deploy something new to the running instances? Or is there anyway to trigger auto-deployment on new instances (Opsworks) when auto scaling?

I am new to AWS, so pardon me if my question is rudimentary.

Carisa answered 18/7, 2015 at 14:57 Comment(0)
E
8

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

To do this, use the AutoScalingRollingUpdate property for the auto-scaling group. When you then change ImageId for the launch configuration, AWS will automatically replace your old servers with new ones as a rolling upgrade.

I have a simple deploy script that creates a new AMI, replaces ImageId in the template, and then does a stack update - AWS takes care of the rest.

Esposito answered 18/7, 2015 at 15:13 Comment(0)
B
5

When creating EC2 instances from Beanstalk, it automatically creates a AutoScaling Group and Launch Configuration based on the specified environment selections. Creating the instance from base AMI is done using a custom code call user data which includes the shell script to create folders and install relevant software.

You can add a new shell scripts or commands there to do your custom work before starting a new instance. This way it is much simpler. e.g. you can run yum update before starting a instance

To find user data section Go to EC2 Console -> Go to launch configurations section (on left) -> Select the correct launch configuration and copy it -> Click view user data -> Add your scripts and commands as required -> Modify the relevant Auto Scaling group to point to the new launch configuration

Burnham answered 19/7, 2015 at 11:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.