How to automatically cycle a new image in an AWS Auto Scaling Group

amazon ec2amazon-web-servicesautoscaling

I have a web application setup with a load balancer and auto scaling group to manage scaling. The source code is in a git repository so I don't have to update the images when the code changes, but occasionally the environment changes so we create a new image. Then that image needs to be cycled into the auto scaling group.

Is there a way to cycle the images automatically? Right now I schedule a scale up and scale down action which gets rid of the old instances.

Best Answer

I'd like to suggest "AWS-HA-Release" to do this - the way AWS-HA-Release works:

  1. If the current autoscaling group and ELB report 5 instances that are healthy,
  2. AWS-HA-Release brings a new instance into production and waits for the ELB to identify it as healthy (bring the total number of healthy instances to 6)
  3. Removes an old instance (total down to 5)
  4. Brings another instance into service (total to 6)
  5. Removes an old instance (total down to 5)
  6. and so on until all instances have been replaced

In this case, you can ship new code or new AMI versions without downtime and have the benefit of entirely new instances. The AWS-HA-Release tool is available at https://github.com/colinbjohnson/aws-missing-tools.

Related Topic