Cloud formation - updating a stack behind an elb doesnt update the AMI
amazon-ec2, amazon-elb, amazon-web-services, autoscaling, aws-cloudformation
Solution
OK - Done some experiments. You need to define an update policy for the scaling group. By defining an update policy, any change in the launch configuration will then trigger an update. Without this - an update won't be triggered.
You don't need an ELB in order to trigger the rolling update, but if you have one, it also won't interfere with it.
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html
Problem
We are powering our AWS EC2 instances using cloud formation. We have 3 different stacks - testing, staging and production. Our workflow to update the images for any of the stacks is as follows: - Update a 'golden master' instance - Snapshot the golden master to a disk image - Change the ami reference in our cloud-formation config (via a json file) for a given stack and `update` the stack. This brings down the instances in the stack + re-provisions them with the new disk image. We've had no problems with our testing or staging stacks, which contain a single ec2 instance each. Each time we update, the image is replaced no problem. Our production stack doesn't seem to be working in the same way :-(. It contains (at least) 2 instances sitting behind a load balancer. When we update this stack in the same way, the ec2 instances are not refreshed straight away (i.e after the update is completed, the boxes are still running from the previous disk image). The good news is the new images are used when the load balancer autoscales. Could there be a conflict between the load balancing rules and cloud formation? Any insight would be greatly appreciated