AWS CloudFormation
User Guide (Version )

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

AWS::AutoScaling::ScheduledAction

Specifies a scheduled scaling action for an Amazon EC2 Auto Scaling group, changing the number of servers available for your application in response to predictable load changes.

Important

When you update a stack with an Auto Scaling group and scheduled action, AWS CloudFormation always sets the min size, max size, and desired capacity properties of your group to the values that are defined in the AWS::AutoScaling::AutoScalingGroup section of your template. However, you might not want CloudFormation to do that when you have a scheduled action in effect. You can use an UpdatePolicy attribute to prevent CloudFormation from changing the min size, max size, or desired capacity property values during a stack update unless you modified the individual values in your template.

If you have rolling updates enabled, before you can update the Auto Scaling group, you must suspend scheduled actions by specifying an UpdatePolicy attribute for the Auto Scaling group. You can find sample update policies for rolling updates in the Examples section of the AWS::AutoScaling::AutoScalingGroup documentation.

For more information, see Scheduled Scaling and Suspending and Resuming Scaling Processes in the Amazon EC2 Auto Scaling User Guide.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::AutoScaling::ScheduledAction", "Properties" : { "AutoScalingGroupName" : String, "DesiredCapacity" : Integer, "EndTime" : String, "MaxSize" : Integer, "MinSize" : Integer, "Recurrence" : String, "StartTime" : String } }

YAML

Type: AWS::AutoScaling::ScheduledAction Properties: AutoScalingGroupName: String DesiredCapacity: Integer EndTime: String MaxSize: Integer MinSize: Integer Recurrence: String StartTime: String

Properties

AutoScalingGroupName

The name or Amazon Resource Name (ARN) of the Auto Scaling group.

Required: Yes

Type: String

Update requires: Replacement

DesiredCapacity

The number of Amazon EC2 instances that should be running in the Auto Scaling group.

You must specify at least one of the following properties: MaxSize, MinSize, or DesiredCapacity.

Required: Conditional

Type: Integer

Update requires: No interruption

EndTime

The date and time in UTC for the recurring schedule to end. For example, "2019-06-01T00:00:00Z".

Required: No

Type: String

Update requires: No interruption

MaxSize

The maximum number of Amazon EC2 instances in the Auto Scaling group.

You must specify at least one of the following properties: MaxSize, MinSize, or DesiredCapacity.

Required: Conditional

Type: Integer

Update requires: No interruption

MinSize

The minimum number of Amazon EC2 instances in the Auto Scaling group.

You must specify at least one of the following properties: MaxSize, MinSize, or DesiredCapacity.

Required: Conditional

Type: Integer

Update requires: No interruption

Recurrence

The recurring schedule for this action, in Unix cron syntax format. For more information about cron syntax, see Crontab.

Specifying the StartTime and EndTime properties with Recurrence property forms the start and stop boundaries of the recurring action.

Required: No

Type: String

Update requires: No interruption

StartTime

The date and time in UTC for this action to start. For example, "2019-06-01T00:00:00Z".

Required: No

Type: String

Update requires: No interruption

Return Values

Ref

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

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

Examples

The following example schedule scaling actions for an Auto Scaling group.

Scheduled Scaling Action

The following template snippet includes two scheduled actions that scale the number of instances in an Auto Scaling group. The ScheduledActionOut action starts at 7 AM every day and sets the Auto Scaling group to a minimum of five Amazon EC2 instances with a maximum of 10. The ScheduledActionIn action starts at 7 PM every day and sets the Auto Scaling group to a minimum and maximum of one Amazon EC2 instance.

JSON

{ "ScheduledActionOut":{ "Type":"AWS::AutoScaling::ScheduledAction", "Properties":{ "AutoScalingGroupName":{ "Ref":"myASGroup" }, "MaxSize":"10", "MinSize":"5", "Recurrence":"0 7 * * *" } }, "ScheduledActionIn":{ "Type":"AWS::AutoScaling::ScheduledAction", "Properties":{ "AutoScalingGroupName":{ "Ref":"myASGroup" }, "MaxSize":"1", "MinSize":"1", "Recurrence":"0 19 * * *" } } }

YAML

ScheduledActionOut: Type: AWS::AutoScaling::ScheduledAction Properties: AutoScalingGroupName: Ref: "myASGroup" MaxSize: 10 MinSize: 5 Recurrence: "0 7 * * *" ScheduledActionIn: Type: AWS::AutoScaling::ScheduledAction Properties: AutoScalingGroupName: Ref: "myASGroup" MaxSize: 1 MinSize: 1 Recurrence: "0 19 * * *"