How do I initiate rolling updates when there are no changes to the launch configuration in CloudFormation?
2 minute read
I want to initiate rolling updates in my Auto Scaling group on every AWS CloudFormation stack update, without modifying the launch configuration.
You can initiate rolling updates for an Auto Scaling group only if you meet specific conditions of the UpdatePolicy attribute.
To initiate rolling updates, you can create a toggle parameter in the launch configuration of your CloudFormation template. However, if you change the value of the toggle parameter during a stack update, then the UserData property is modified. Any modification to UserData requires replacement. CloudFormation detects the modification to UserData, and then replaces the LaunchConfiguration resource. This replacement initiates the Auto Scaling rolling update, as defined by the UpdatePolicy attribute.
The following steps assume that your AutoScalingRollingUpdate policy is configured for your Auto Scaling group, and your Auto Scaling group is configured to reference LaunchConfiguration.
Important: Make sure that you don't disrupt other elements in the UserData property when you add the toggle parameter to your template. Also, don't add the toggle parameter before cfn-signal.
1. In your CloudFormation template, define Toggle as the parameter.