AWS CloudFormation
User Guide (API Version 2010-05-15)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

UpdatePolicy Attribute

You can use the UpdatePolicy attribute to specify how AWS CloudFormation handles updates to the AWS::AutoScaling::AutoScalingGroup resource.

Currently, the only AWS CloudFormation resource that supports update policies is AWS::AutoScaling::AutoScalingGroup. The update policy is invoked under the following conditions:

  • The AutoScalingRollingUpdate policy is applied when you make a change to the Auto Scaling placement group, launch configuration, or subnet group membership of the Auto Scaling group.

  • The AutoScalingScheduledAction policy is applied when you update a stack that includes an Auto Scaling group with an associated scheduled action.

Syntax

"UpdatePolicy" : {
   "AutoScalingRollingUpdate" : {
      "MaxBatchSize" : String,
      "MinInstancesInService" : String,
      "PauseTime" : String
   },
   "AutoScalingScheduledAction" : {
      "IgnoreUnmodifiedGroupSizeProperties" : Boolean
   }
}

AutoScalingRollingUpdate Properties

You can use the AutoScalingRollingUpdate policy to specify how AWS CloudFormation handles rolling updates for a particular resource.

Important

If you have enabled rolling updates and scheduled actions, you must suspend scheduled actions before you can update the Auto Scaling group. You can suspend processes by using the AWS CLI or Auto Scaling API. For more information, see Suspend and Resume Auto Scaling Process in the Auto Scaling Developer Guide.

MaxBatchSize

The maximum number of instances that are terminated at a given time.

Default: 1

Type: String

Required: No

MinInstancesInService

The minimum number of instances that must be in service within the autoscaling group while obsolete instances are being terminated.

Default: 0

Type: String

Required: No

PauseTime

The amount of time to pause before changes are made to a resource, for example, before adding or removing auto-scaling instances when scaling up or terminating instances in an auto-scaling group.

The value must be in ISO8601 duration format, in the form: "PT#H#M#S", where each # is the number of hours, minutes, and/or seconds, respectively. The maximum amount of time that can be specified for the pause time is one hour ("PT1H").

Default: PT0S (zero seconds)

Type: String

Required: No

AutoScalingScheduledAction Properties

When the AWS::AutoScaling::AutoScalingGroup resource has an associated scheduled action, the AutoScalingScheduledAction policy describes how AWS CloudFormation handles updates for the MinSize, MaxSize, and DesiredCapacity properties..

With scheduled actions, the group size properties (minimum size, maximum size, and desired capacity) of an Auto Scaling group can change at any time. Whenever you update a stack with an Auto Scaling group and scheduled action, AWS CloudFormation always sets group size property values of your Auto Scaling group to the values that are defined in the AWS::AutoScaling::AutoScalingGroup resource of your template, even if a scheduled action is in effect. However, you might not want AWS CloudFormation to change any of the group size property values, such as when you have a scheduled action in effect. You can use the AutoScalingScheduledAction update policy to prevent AWS CloudFormation from changing the min size, max size, or desired capacity unless you modified the individual values in your template.

IgnoreUnmodifiedGroupSizeProperties

During a stack update, indicates whether AWS CloudFormation ignores any group size property differences between your current Auto Scaling group and the Auto Scaling group that is described in the AWS::AutoScaling::AutoScalingGroup resource of your template. However, if you modified any group size property values in your template, AWS CloudFormation will always use the modified values and update your Auto Scaling group.

Default: false

Type: Boolean

Required: No.

Examples

The following example shows how to add an update policy to an autoscaling group.

"ASG" : {
   "Type" : "AWS :  : AutoScaling :  : AutoScalingGroup",
   "Properties" : {
      "AvailabilityZones" : [
         "us-east-1a",
         "us-east-1b"
      ],
      "DesiredCapacity" : "1",
      "LaunchConfigurationName" : {
         "Ref" : "LaunchConfig"
      },
      "MaxSize" : "4",
      "MinSize" : "1"
   },
   "UpdatePolicy" : {
      "AutoScalingScheduledAction" : {
         "IgnoreUnmodifiedGroupSizeProperties" : "true"
      },
      "AutoScalingRollingUpdate" : {
         "MinInstancesInService" : "1",
         "MaxBatchSize" : "2",
         "PauseTime" : "PT1M"
      }
   }
 },
"ScheduledAction" : {
   "Type" : "AWS :  : AutoScaling :  : ScheduledAction",
   "Properties" : {
      "AutoScalingGroupName" : {
         "Ref" : "ASG"
      },
      "DesiredCapacity" : "2",
      "StartTime" : "2017-06-02T20 : 00 : 00Z"
   }
}