Search code examples
amazon-web-servicescloudautoscalingaws-opsworks

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


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.


Solution

  • 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.