I\'m working with a CloudFormation template that brings up as many instances as I request, and want to wait for them to finish initialising (via User Data) before the stack crea
The AutoScalingRollingUpdate policy handles rotating out an entire set of instances in an Auto Scaling group in response to changes to the underlying LaunchConfiguration
. It doesn't apply to individual changes to the number of instances in the existing group. According to the UpdatePolicy Attribute documentation,
The
AutoScalingReplacingUpdate
andAutoScalingRollingUpdate
policies apply only when you do one or more of the following:
- Change the Auto Scaling group's
AWS::AutoScaling::LaunchConfiguration
.- Change the Auto Scaling group's
VPCZoneIdentifier
property- Update an Auto Scaling group that contains instances that don't match the current
LaunchConfiguration
.
Changing the Auto Scaling group's DesiredCapacity
property is not in this list, so the AutoScalingRollingUpdate
policy does not apply to this type of change.
As far as I know, it is not possible (using standard AWS CloudFormation resources) to delay the completion of a Stack Update modifying DesiredCapacity
until any new instances added to the Auto Scaling Group are fully provisioned.
Here are some alternative options:
DesiredCapacity
, modify a LaunchConfiguration
property at the same time. This will trigger an AutoScalingRollingUpdate
to the desired capacity (the downside is that it will also update existing instances, which may not actually need to be modified).cfn-signal
, to signal lifecycle-hook completion. This won't delay your CloudFormation stack update as desired, but it will delay the individual auto-scaled instances from entering the InService
state until the lifecycle signal is received. (See Lifecycle Hooks documentation for more info.)DesiredCapacity
number of instances all in the InService
state.the rolling update only works for existing instances. The documentation says:
Rolling updates enable you to specify whether AWS CloudFormation updates instances that are in an Auto Scaling group in batches or all at once.
So to test this, create a stack based on your template. than make a small modification to the launch config (e.g. set sleep 120 to 121) and update the stack. now you should see a rolling update.