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...

AWS::AutoScaling::AutoScalingGroup

The AWS::AutoScaling::AutoScalingGroup type creates an Auto Scaling group.

You can add an UpdatePolicy attribute to your auto-scaling group to control how rolling updates are performed when a change has been made to the auto scaling group's launch configuration or subnet group membership.

Syntax

{
   "Type" : "AWS::AutoScaling::AutoScalingGroup",
   "Properties" : {
      "AvailabilityZones" : [ String, ... ],
      "Cooldown" : String,
      "DesiredCapacity" : String,
      "HealthCheckGracePeriod" : Integer,
      "HealthCheckType" : String,
      "InstanceId" : String,
      "LaunchConfigurationName" : String,
      "LoadBalancerNames" : [ String, ... ],
      "MaxSize" : String,
      "MinSize" : String,
      "NotificationConfiguration" : NotificationConfiguration,
      "Tags" : [ Auto Scaling Tag, ..., ],
      "TerminationPolicies" : [ String, ..., ],
      "VPCZoneIdentifier" : [ String, ... ]
   }
}     

Properties

AvailabilityZones

Contains a list of availability zones for the group.

Required: Yes

Type: A list of strings

Cooldown

The number of seconds after a scaling activity completes before any further scaling activities can start.

Required: No

Type: String

DesiredCapacity

Specifies the desired capacity for the auto scaling group.

If SpotPrice is not set in the AWS::AutoScaling::LaunchConfiguration for this auto scaling group, then Auto Scaling will begin to bring up instances based on DesiredCapacity. CloudFormation will not mark the auto scaling group as successful (by setting its status to CREATE_COMPLETE) until the desired capacity is reached.

If SpotPrice is set, then DesiredCapacity will not be used as a criteria for success, since instances will only be run when the spot price has been matched. Once the spot price has been matched, however, Auto Scaling will use DesiredCapacity as the target capacity for bringing up instances.

Required: No

Type: String

HealthCheckGracePeriod

The length of time in seconds after a new EC2 instance comes into service that Auto Scaling starts checking its health.

Required: No

Type: Integer

HealthCheckType

The service you want the health status from, Amazon EC2 or Elastic Load Balancer. Valid values are "EC2" or "ELB."

Required: No

Type: String

InstanceId

The ID of the Amazon EC2 instance you want to use to create the Auto Scaling group. Use this property if you want to create an Auto Scaling group by using an existing Amazon EC2 instance instead of a launch configuration.

When you use an Amazon EC2 instance to create an Auto Scaling group, a new launch configuration is first created and then associated with the Auto Scaling group. The new launch configuration derives all its properties from the instance, with the exception of BlockDeviceMapping and AssociatePublicIpAddress.

Required: Conditional. You must specify this property if you don't specify the LaunchConfigurationName property.

Type: String

Update requires: Replacement

LaunchConfigurationName

Specifies the name of the associated AWS::AutoScaling::LaunchConfiguration.

Note

If this resource has a public IP address and is also in a VPC that is defined in the same template, you must use the DependsOn attribute to declare a dependency on the VPC-gateway attachment. For more information, see DependsOn Attribute.

Required: Conditional, you must specify this property if you don't specify the InstanceId property.

Type: String

Update requires: no interruption

Important

When you update the LaunchConfigurationName, existing Amazon EC2 instances continue to run with the configuration that they were originally launched with. To update existing instances, specify an update policy attribute for this Auto Scaling group. For more information, see UpdatePolicy.

LoadBalancerNames

A list of load balancers associated with this Auto Scaling group.

Required: No

Type: List of Strings

Update requires: Replacement

Important

When you update LoadBalancerNames, the entire Auto Scaling group is replaced.

MaxSize

The maximum size of the auto scaling group.

Required: Yes

Type: String

MinSize

The minimum size of the auto scaling group.

Required: Yes

Type: String

NotificationConfiguration

An embedded property that configures an auto scaling group to send notifications when specified events take place.

Required: No

Type: NotificationConfiguration

Tags

The tags you want to attach to this resource.

For more information about tags, go to Tagging Auto Scaling Groups and Amazon EC2 Instances in the Auto Scaling Developer Guide.

Required: No

Type: List of Auto Scaling Tags

Update requires: no interruption

TerminationPolicies

A termination policy or a list of termination policies that are used to select the instances to terminate. The policies are executed in the order that you list them.

For more information on configuring a termination policy for your Auto Scaling group, see Instance Termination Policy for Your Auto Scaling Group in the Auto Scaling Developer Guide.

Required: No

Type: A list of strings

Update requires: Replacement

VPCZoneIdentifier

A list of subnet identifiers of Amazon Virtual Private Cloud (Amazon VPCs).

The subnets that you specify for VPCZoneIdentifier must reside in the availability zones that you specify with the AvailabilityZones parameter.

For more information, go to Using EC2 Dedicated Instances Within Your VPC in the Auto Scaling Developer Guide.

Required: No

Type: A list of strings

Update requires: Replacement

Note

When you update VPCZoneIdentifier, the instances are replaced, but not the Auto Scaling group.

Return Value

When the logical ID of this resource is provided to the Ref intrinsic function, it returns the resource name. For example:

{ "Ref": "MyASGroup" }

For an auto scaling group with the logical ID "MyASGroup", Ref will return:

mystack-myasgroup-NT5EUXTNTXXD

For more information about using the Ref function, see Ref.

Examples

Auto scaling group with an elastic load balancer and launch configuration

"WebServerGroup" : {
   "Type" : "AWS::AutoScaling::AutoScalingGroup",
   "Properties" : {
      "AvailabilityZones" : { "Fn::GetAZs" : "" },
      "LaunchConfigurationName" : { "Ref" : "LaunchConfig" },
      "MinSize" : "2",
      "MaxSize" : "2",
      "LoadBalancerNames" : [ { "Ref" : "ElasticLoadBalancer" } ]
   }
}        

Auto scaling group with an update policy

The following example shows how to configure updates by including an UpdatePolicy attribute. The attribute contains an AutoScalingRollingUpdate embedded object with three attributes that specify the update policy settings.

"ASG1" : {
   "UpdatePolicy" : {
      "AutoScalingRollingUpdate" : {
         "MinInstancesInService" : "1",
         "MaxBatchSize" : "1",
         "PauseTime" : "PT12M5S"
      }
   },
   "Type" : "AWS::AutoScaling::AutoScalingGroup",
   "Properties" : {
      "AvailabilityZones" : { "Fn::GetAZs" : { "Ref" : "AWS::Region" } },
      "LaunchConfigurationName" : { "Ref" : "ASLC" },
      "MaxSize" : "3",
      "MinSize" : "1"
   }
}

To view more auto-scaling examples, see Auto Scaling Snippets.