By using AWS re:Post, you agree to the AWS re:Post Terms of Use

How can I update my Auto Scaling group when I update my CloudFormation stack?

3 minute read
2

I updated my Auto Scaling group, but I didn't get the results that I expected during an AWS CloudFormation stack update.

Short description

The AWS::AutoScaling::AutoScalingGroup resource uses the UpdatePolicy attribute to define how an Auto Scaling group resource is updated when the CloudFormation stack is updated. If you don't have the correct settings configured for the UpdatePolicy attribute, then your rolling update can produce unexpected results.

Use the AutoScalingRollingUpdate policy to control how CloudFormation handles rolling updates for an Auto Scaling group.

Note: The following resolution applies only to the AutoScalingRollingUpdate policy.

The AutoScalingRollingUpdate policy supports the following configuration options:

"UpdatePolicy": {  "AutoScalingRollingUpdate": {
    "MaxBatchSize": Integer,
    "MinInstancesInService": Integer,
    "MinSuccessfulInstancesPercent": Integer,
    "PauseTime": String,
    "SuspendProcesses": [ List of processes ],
    "WaitOnResourceSignals": Boolean
  }
}

Resolution

To troubleshoot what's preventing your Auto Scaling group from updating correctly during a stack update, review the following scenarios:

Configure WaitOnResourceSignals and PauseTime to avoid problems with success signals

In your AutoScalingRollingUpdate policy, set the WaitOnResourceSignals property to false.

Note: If WaitOnResourceSignals is set to true, then PauseTime acts as a timeout value. CloudFormation waits to receive a success signal until the maximum time specified by the PauseTime value. If a signal isn't received, CloudFormation cancels the update. Then, CloudFormation rolls back the stack with the same settings, including the same PauseTime value. For more information, see Add an UpdatePolicy to an Auto Scaling Group.

Configure MinSuccessfulInstancesPercent to avoid stack rollback

If you're replacing a large number of instances during a rolling update and are waiting for a success signal for each instance, then set the value of the MinSuccessfulInstancesPercent property in your AutoScalingRollingUpdate policy.

Note: Setting the MinSuccessfulInstancesPercent property prevents CloudFormation from rolling back the entire stack if only a single instance fails to launch. For more information, see UpdatePolicy Attribute.

Configure SuspendProcesses to avoid unexpected changes to the Auto Scaling group

If an unexpected scaling action changes the state of the Auto Scaling group during a rolling update, then the update can fail. To avoid such failures, suspend the following Auto Scaling processes during a rolling update:

  • HealthCheck
  • ReplaceUnhealthy
  • AZRebalance
  • AlarmNotification
  • ScheduledActions
  • InstanceRefresh

Important: If you're using your Auto Scaling group with Elastic Load Balancing, don't suspend the following processes: Launch, Terminate, and AddToLoadBalancer. These processes are necessary for rolling updates.

AWS OFFICIAL
AWS OFFICIALUpdated 5 months ago
2 Comments

If you specify the MinSuccessfulInstancesPercent property, you must also enable the WaitOnResourceSignals and PauseTime properties.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html#cfn-attributes-updatepolicy-rollingupdate-minsuccessfulinstancespercent

AWS
replied a year ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
EXPERT
replied a year ago