Auto scaling template snippets - AWS CloudFormation

Auto scaling template snippets

The following examples show different snippets to include in templates for use with Amazon EC2 Auto Scaling or Application Auto Scaling.

Amazon EC2 Auto Scaling enables you to automatically scale Amazon EC2 instances, either with scaling policies or with scheduled scaling. Auto Scaling groups are collections of Amazon EC2 instances that enable automatic scaling and fleet management features, such as health checks and integration with Elastic Load Balancing.

Application Auto Scaling provides automatic scaling of different resources beyond Amazon EC2, either with scaling policies or with scheduled scaling.

Declaring a launch configuration

This example shows an AWS::AutoScaling::LaunchConfiguration resource for an Auto Scaling group. The SecurityGroups property specifies both an AWS::EC2::SecurityGroup resource named myEC2SecurityGroup and an existing EC2 security group named myExistingEC2SecurityGroup. The BlockDeviceMappings property lists two devices: a 50 gigabyte EBS volume mapped to /dev/sdk and a virtual device ephemeral0 mapped to /dev/sdc.

JSON

"SimpleConfig" : { "Type" : "AWS::AutoScaling::LaunchConfiguration", "Properties" : { "ImageId" : "ami-0ff8a91507f77f867", "SecurityGroups" : [ { "Ref" : "myEC2SecurityGroup" }, "myExistingEC2SecurityGroup" ], "InstanceType" : "m1.small", "BlockDeviceMappings" : [ { "DeviceName" : "/dev/sdk", "Ebs" : {"VolumeSize" : "50"} }, { "DeviceName" : "/dev/sdc", "VirtualName" : "ephemeral0" } ] } }

YAML

SimpleConfig: Type: AWS::AutoScaling::LaunchConfiguration Properties: ImageId: ami-0ff8a91507f77f867 SecurityGroups: - Ref: myEC2SecurityGroup - myExistingEC2SecurityGroup InstanceType: m1.small BlockDeviceMappings: - DeviceName: "/dev/sdk" Ebs: VolumeSize: '50' - DeviceName: "/dev/sdc" VirtualName: ephemeral0

Declaring an Auto Scaling group

This example shows an AWS::AutoScaling::AutoScalingGroup resource. The AvailabilityZones property specifies the Availability Zones where the Auto Scaling group's EC2 instances will be created. In this example, the Fn::GetAZs function call { "Fn::GetAZs" : "" } specifies all Availability Zones for the region in which the stack is created. The LoadBalancerNames property lists the LoadBalancers used to route traffic to the Auto Scaling group. In this example, one LoadBalancer is specified, the AWS::ElasticLoadBalancing::LoadBalancer resource LB.

JSON

"MyServerGroup" : { "Type" : "AWS::AutoScaling::AutoScalingGroup", "Properties" : { "AvailabilityZones" : { "Fn::GetAZs" : ""}, "LaunchConfigurationName" : { "Ref" : "SimpleConfig" }, "MinSize" : "1", "MaxSize" : "3", "LoadBalancerNames" : [ { "Ref" : "LB" } ] } }

YAML

MyServerGroup: Type: AWS::AutoScaling::AutoScalingGroup Properties: AvailabilityZones: Fn::GetAZs: '' LaunchConfigurationName: Ref: SimpleConfig MinSize: '1' MaxSize: '3' LoadBalancerNames: - Ref: LB

Declaring a scaling policy with a CloudWatch alarm

This example shows an AWS::AutoScaling::ScalingPolicy resource that scales up the Auto Scaling group asGroup using a simple scaling policy. The AdjustmentType property specifies ChangeInCapacity, which means that the ScalingAdjustment represents the number of instances to add (if ScalingAdjustment is positive) or delete (if it is negative). In this example, ScalingAdjustment is 1; therefore, the policy increments the number of EC2 instances in the group by 1 when the alarm threshold is breached.

The AWS::CloudWatch::Alarm resource CPUAlarmHigh specifies the scaling policy ScaleUpPolicy as the action to run when the alarm is in an ALARM state (AlarmActions).

JSON

"ScaleUpPolicy" : { "Type" : "AWS::AutoScaling::ScalingPolicy", "Properties" : { "AdjustmentType" : "ChangeInCapacity", "AutoScalingGroupName" : { "Ref" : "asGroup" }, "Cooldown" : "1", "ScalingAdjustment" : "1" } }, "CPUAlarmHigh": { "Type": "AWS::CloudWatch::Alarm", "Properties": { "EvaluationPeriods": "1", "Statistic": "Average", "Threshold": "10", "AlarmDescription": "Alarm if CPU too high or metric disappears indicating instance is down", "Period": "60", "AlarmActions": [ { "Ref": "ScaleUpPolicy" } ], "Namespace": "AWS/EC2", "Dimensions": [ { "Name": "AutoScalingGroupName", "Value": { "Ref": "asGroup" } } ], "ComparisonOperator": "GreaterThanThreshold", "MetricName": "CPUUtilization" } }

YAML

ScaleUpPolicy: Type: AWS::AutoScaling::ScalingPolicy Properties: AdjustmentType: ChangeInCapacity AutoScalingGroupName: Ref: asGroup Cooldown: '1' ScalingAdjustment: '1' CPUAlarmHigh: Type: AWS::CloudWatch::Alarm Properties: EvaluationPeriods: '1' Statistic: Average Threshold: '10' AlarmDescription: Alarm if CPU too high or metric disappears indicating instance is down Period: '60' AlarmActions: - Ref: ScaleUpPolicy Namespace: AWS/EC2 Dimensions: - Name: AutoScalingGroupName Value: Ref: asGroup ComparisonOperator: GreaterThanThreshold MetricName: CPUUtilization

See also

For example templates for the TargetTrackingScaling and StepScaling policy types, see AWS::AutoScaling::ScalingPolicy.

Declaring an Auto Scaling group with notifications

This example shows an AWS::AutoScaling::AutoScalingGroup resource that sends Amazon SNS notifications when the specified events take place. The NotificationConfigurations property specifies the SNS topic where AWS CloudFormation sends a notification and the events that will cause AWS CloudFormation to send notifications. When the events specified by NotificationTypes occur, AWS CloudFormation will send a notification to the SNS topic specified by TopicARN. In this example, AWS CloudFormation sends a notification to the SNS topic topic1 when the autoscaling:EC2_INSTANCE_LAUNCH and autoscaling:EC2_INSTANCE_LAUNCH_ERROR events occur.

JSON

"MyAsGroupWithNotification" : { "Type" : "AWS::AutoScaling::AutoScalingGroup", "Properties" : { "AvailabilityZones" : { "Ref" : "azList" }, "LaunchConfigurationName" : { "Ref" : "myLCOne" }, "MinSize" : "0", "MaxSize" : "2", "DesiredCapacity" : "1", "NotificationConfigurations" : [ { "TopicARN" : { "Ref" : "topic1" }, "NotificationTypes" : [ "autoscaling:EC2_INSTANCE_LAUNCH", "autoscaling:EC2_INSTANCE_LAUNCH_ERROR", "autoscaling:EC2_INSTANCE_TERMINATE", "autoscaling:EC2_INSTANCE_TERMINATE_ERROR" ] } ] } }

YAML

MyAsGroupWithNotification: Type: AWS::AutoScaling::AutoScalingGroup Properties: AvailabilityZones: Ref: azList LaunchConfigurationName: Ref: myLCOne MinSize: '0' MaxSize: '2' DesiredCapacity: '1' NotificationConfigurations: - TopicARN: Ref: topic1 NotificationTypes: - autoscaling:EC2_INSTANCE_LAUNCH - autoscaling:EC2_INSTANCE_LAUNCH_ERROR - autoscaling:EC2_INSTANCE_TERMINATE - autoscaling:EC2_INSTANCE_TERMINATE_ERROR

Declaring an Auto Scaling group with an UpdatePolicy

This example shows how to use an UpdatePolicy attribute with an Auto Scaling group.

JSON

"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" } }

YAML

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'

Application Auto Scaling template examples

This section provides AWS CloudFormation template examples for Application Auto Scaling scaling policies and scheduled actions for different AWS resources.

Important

When an Application Auto Scaling snippet is included in the template, you should declare a dependency on the specific scalable resource that is created through the template using the DependsOn attribute. This overrides the default parallelism and directs AWS CloudFormation to operate on resources in a specified order. Otherwise, the scaling configuration might be applied before the resource has been set up completely.

Declaring a scaling policy for an Aurora DB cluster

In this snippet, you register an AWS::RDS::DBCluster resource named my-db-cluster. The AWS::ApplicationAutoScaling::ScalableTarget resource indicates that the DB cluster should be dynamically scaled to have from one to eight Aurora Replicas. You also apply a target tracking scaling policy named AuroraScalingPolicy to the cluster using the AWS::ApplicationAutoScaling::ScalingPolicy resource.

In this configuration, the RDSReaderAverageCPUUtilization predefined metric is used to adjust an Aurora DB cluster based on an average CPU utilization of 40 percent across all Aurora Replicas in that Aurora DB cluster. The configuration provides a scale-in cooldown period of 10 minutes and a scale-out cooldown period of 5 minutes.

JSON

{ "Resources":{ "ScalableTarget":{ "Type":"AWS::ApplicationAutoScaling::ScalableTarget", "Properties":{ "MaxCapacity":8, "MinCapacity":1, "RoleARN":{ "Fn::Sub":"arn:aws:iam::${AWS::AccountId}:role/aws-service-role/rds.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_RDSCluster" }, "ServiceNamespace":"rds", "ScalableDimension":"rds:cluster:ReadReplicaCount", "ResourceId":"cluster:my-db-cluster" } }, "ScalingPolicyDBCluster":{ "Type":"AWS::ApplicationAutoScaling::ScalingPolicy", "Properties":{ "PolicyName":"AuroraScalingPolicy", "PolicyType":"TargetTrackingScaling", "ServiceNamespace":"rds", "ScalableDimension":"rds:cluster:ReadReplicaCount", "ResourceId":"cluster:my-db-cluster", "TargetTrackingScalingPolicyConfiguration":{ "TargetValue":40, "PredefinedMetricSpecification":{ "PredefinedMetricType":"RDSReaderAverageCPUUtilization" }, "ScaleInCooldown":600, "ScaleOutCooldown":300 } } } } }

YAML

--- Resources: ScalableTarget: Type: 'AWS::ApplicationAutoScaling::ScalableTarget' Properties: MaxCapacity: 8 MinCapacity: 1 RoleARN: Fn::Sub: 'arn:aws:iam::${AWS::AccountId}:role/aws-service-role/rds.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_RDSCluster' ServiceNamespace: rds ScalableDimension: 'rds:cluster:ReadReplicaCount' ResourceId: 'cluster:my-db-cluster' ScalingPolicyDBCluster: Type: 'AWS::ApplicationAutoScaling::ScalingPolicy' Properties: PolicyName: AuroraScalingPolicy PolicyType: TargetTrackingScaling ServiceNamespace: rds ScalableDimension: 'rds:cluster:ReadReplicaCount' ResourceId: 'cluster:my-db-cluster' TargetTrackingScalingPolicyConfiguration: TargetValue: 40 PredefinedMetricSpecification: PredefinedMetricType: RDSReaderAverageCPUUtilization ScaleInCooldown: 600 ScaleOutCooldown: 300

Declaring a scaling policy for a DynamoDB table

This snippet shows how to create a policy with the TargetTrackingScaling policy type and apply it to an AWS::DynamoDB::Table resource using the AWS::ApplicationAutoScaling::ScalingPolicy resource. The AWS::ApplicationAutoScaling::ScalableTarget resource declares a scalable target to which this policy is applied, with a minimum of five write capacity units and a maximum of 15. The scaling policy scales the table's write capacity throughput to maintain the target utilization at 50 percent based on the write capacity utilization metric.

Note

For more information about how to create a AWS CloudFormation template for DynamoDB resources, see How to use AWS CloudFormation to configure auto scaling for Amazon DynamoDB tables and indexes.

JSON

{ "Resources":{ "WriteCapacityScalableTarget":{ "Type":"AWS::ApplicationAutoScaling::ScalableTarget", "Properties":{ "MaxCapacity":15, "MinCapacity":5, "RoleARN":{ "Fn::Sub":"arn:aws:iam::${AWS::AccountId}:role/aws-service-role/dynamodb.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_DynamoDBTable" }, "ServiceNamespace":"dynamodb", "ScalableDimension":"dynamodb:table:WriteCapacityUnits", "ResourceId":{ "Fn::Join":[ "/", [ "table", { "Ref":"DDBTable" } ] ] } } }, "WriteScalingPolicy":{ "Type":"AWS::ApplicationAutoScaling::ScalingPolicy", "Properties":{ "PolicyName":"WriteScalingPolicy", "PolicyType":"TargetTrackingScaling", "ScalingTargetId":{ "Ref":"WriteCapacityScalableTarget" }, "TargetTrackingScalingPolicyConfiguration":{ "TargetValue":50.0, "ScaleInCooldown":60, "ScaleOutCooldown":60, "PredefinedMetricSpecification":{ "PredefinedMetricType":"DynamoDBWriteCapacityUtilization" } } } } } }

YAML

--- Resources: WriteCapacityScalableTarget: Type: AWS::ApplicationAutoScaling::ScalableTarget Properties: MaxCapacity: 15 MinCapacity: 5 RoleARN: Fn::Sub: 'arn:aws:iam::${AWS::AccountId}:role/aws-service-role/dynamodb.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_DynamoDBTable' ServiceNamespace: dynamodb ScalableDimension: dynamodb:table:WriteCapacityUnits ResourceId: !Join - / - - table - !Ref DDBTable WriteScalingPolicy: Type: AWS::ApplicationAutoScaling::ScalingPolicy Properties: PolicyName: WriteScalingPolicy PolicyType: TargetTrackingScaling ScalingTargetId: !Ref WriteCapacityScalableTarget TargetTrackingScalingPolicyConfiguration: TargetValue: 50.0 ScaleInCooldown: 60 ScaleOutCooldown: 60 PredefinedMetricSpecification: PredefinedMetricType: DynamoDBWriteCapacityUtilization

Declaring a scaling policy for an Amazon ECS service

This snippet shows how to create a policy and apply it to an AWS::ECS::Service resource using the AWS::ApplicationAutoScaling::ScalingPolicy resource. The AWS::ApplicationAutoScaling::ScalableTarget resource declares a scalable target to which this policy is applied. Application Auto Scaling can scale the number of tasks at a minimum of 1 task and a maximum of 2.

This example creates two scaling policies with the TargetTrackingScaling policy type. The policies are used to scale the ECS service based on the service's average CPU and memory usage.

JSON

{ "Resources":{ "ECSScalableTarget":{ "Type":"AWS::ApplicationAutoScaling::ScalableTarget", "Properties":{ "MaxCapacity":"2", "MinCapacity":"1", "RoleARN":{ "Fn::Sub":"arn:aws:iam::${AWS::AccountId}:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService" }, "ServiceNamespace":"ecs", "ScalableDimension":"ecs:service:DesiredCount", "ResourceId":{ "Fn::Join":[ "/", [ "service", { "Ref":"cluster" }, { "Fn::GetAtt":[ "service", "Name" ] } ] ] } } }, "ServiceScalingPolicyCPU":{ "Type":"AWS::ApplicationAutoScaling::ScalingPolicy", "Properties":{ "PolicyName":{"Fn::Sub":"${AWS::StackName}-target-tracking-cpu70"}, "PolicyType":"TargetTrackingScaling", "ScalingTargetId":{ "Ref":"ECSScalableTarget" }, "TargetTrackingScalingPolicyConfiguration":{ "TargetValue":70.0, "ScaleInCooldown":180, "ScaleOutCooldown":60, "PredefinedMetricSpecification":{ "PredefinedMetricType":"ECSServiceAverageCPUUtilization" } } } }, "ServiceScalingPolicyMem":{ "Type":"AWS::ApplicationAutoScaling::ScalingPolicy", "Properties":{ "PolicyName":{"Fn::Sub":"${AWS::StackName}-target-tracking-mem90"}, "PolicyType":"TargetTrackingScaling", "ScalingTargetId":{ "Ref":"ECSScalableTarget" }, "TargetTrackingScalingPolicyConfiguration":{ "TargetValue":90.0, "ScaleInCooldown":180, "ScaleOutCooldown":60, "PredefinedMetricSpecification":{ "PredefinedMetricType":"ECSServiceAverageMemoryUtilization" } } } } } }

YAML

--- Resources: ECSScalableTarget: Type: AWS::ApplicationAutoScaling::ScalableTarget Properties: MaxCapacity: '2' MinCapacity: '1' RoleARN: Fn::Sub: 'arn:aws:iam::${AWS::AccountId}:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService' ServiceNamespace: ecs ScalableDimension: 'ecs:service:DesiredCount' ResourceId: !Join - / - - service - !Ref cluster - !GetAtt service.Name ServiceScalingPolicyCPU: Type: AWS::ApplicationAutoScaling::ScalingPolicy Properties: PolicyName: !Sub ${AWS::StackName}-target-tracking-cpu70 PolicyType: TargetTrackingScaling ScalingTargetId: Ref: ECSScalableTarget TargetTrackingScalingPolicyConfiguration: TargetValue: 70.0 ScaleInCooldown: 180 ScaleOutCooldown: 60 PredefinedMetricSpecification: PredefinedMetricType: ECSServiceAverageCPUUtilization ServiceScalingPolicyMem: Type: AWS::ApplicationAutoScaling::ScalingPolicy Properties: PolicyName: !Sub ${AWS::StackName}-target-tracking-mem90 PolicyType: TargetTrackingScaling ScalingTargetId: Ref: ECSScalableTarget TargetTrackingScalingPolicyConfiguration: TargetValue: 90.0 ScaleInCooldown: 180 ScaleOutCooldown: 60 PredefinedMetricSpecification: PredefinedMetricType: ECSServiceAverageMemoryUtilization

The following AWS::ApplicationAutoScaling::ScalingPolicy resource applies a target tracking scaling policy with the ALBRequestCountPerTarget predefined metric to an ECS service named web-app in the default cluster. The policy is used to add capacity to the ECS service when the request count per target exceeds the target value. Because the value of DisableScaleIn is set to true, the target tracking policy won't remove capacity from the scalable target.

JSON

{ "Resources":{ "ServiceScalingPolicyALB":{ "Type":"AWS::ApplicationAutoScaling::ScalingPolicy", "Properties":{ "PolicyName":"alb-scale-out-target-tracking-scaling-policy", "PolicyType":"TargetTrackingScaling", "ServiceNamespace":"ecs", "ScalableDimension":"ecs:service:DesiredCount", "ResourceId":"service/default/web-app", "TargetTrackingScalingPolicyConfiguration":{ "TargetValue":1000.0, "ScaleInCooldown":60, "ScaleOutCooldown":60, "DisableScaleIn":true, "PredefinedMetricSpecification":{ "PredefinedMetricType":"ALBRequestCountPerTarget", "ResourceLabel": "app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d" } } } } } }

YAML

--- Resources: ServiceScalingPolicyALB: Type: AWS::ApplicationAutoScaling::ScalingPolicy Properties: PolicyName: alb-scale-out-target-tracking-scaling-policy PolicyType: TargetTrackingScaling ServiceNamespace: ecs ScalableDimension: ecs:service:DesiredCount ResourceId: service/default/web-app TargetTrackingScalingPolicyConfiguration: TargetValue: 1000.0 ScaleInCooldown: 60 ScaleOutCooldown: 60 DisableScaleIn: true PredefinedMetricSpecification: PredefinedMetricType: ALBRequestCountPerTarget ResourceLabel: app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d

Declaring a scheduled action for a Lambda function

This snippet registers the provisioned concurrency for a function alias (AWS::Lambda::Alias) named BLUE, with a minimum capacity of 1 and a maximum capacity of 100, using the AWS::ApplicationAutoScaling::ScalableTarget resource. It also creates a scheduled action with a recurring schedule using a cron expression.

It uses the Fn::Join and Ref intrinsic functions in the RoleARN property to specify the ARN of the service-linked role. It uses the Fn::Sub intrinsic function to construct the ResourceId property.

Note: You can't allocate provisioned concurrency on an alias that points to the unpublished version ($LATEST).

JSON

{ "ScalableTarget":{ "Type":"AWS::ApplicationAutoScaling::ScalableTarget", "Properties":{ "MaxCapacity":100, "MinCapacity":1, "RoleARN":{ "Fn::Join":[ ":", [ "arn:aws:iam:", { "Ref":"AWS::AccountId" }, "role/aws-service-role/lambda.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_LambdaConcurrency" ] ] }, "ServiceNamespace":"lambda", "ScalableDimension":"lambda:function:ProvisionedConcurrency", "ResourceId":{ "Fn::Sub":"function:${MyFunction}:BLUE" }, "ScheduledActions":[ { "EndTime":"2019-12-31T12:00:00.000Z", "ScalableTargetAction":{ "MaxCapacity":"500", "MinCapacity":"50" }, "ScheduledActionName":"First", "StartTime":"2019-12-25T12:00:00.000Z", "Schedule":"cron(0 18 * * ? *)" } ] } } }

YAML

ScalableTarget: Type: AWS::ApplicationAutoScaling::ScalableTarget Properties: MaxCapacity: 100 MinCapacity: 1 RoleARN: !Join - ':' - - 'arn:aws:iam:' - !Ref 'AWS::AccountId' - role/aws-service-role/lambda.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_LambdaConcurrency ServiceNamespace: lambda ScalableDimension: lambda:function:ProvisionedConcurrency ResourceId: !Sub function:${MyFunction}:BLUE ScheduledActions: - EndTime: '2019-12-31T12:00:00.000Z' ScalableTargetAction: MaxCapacity: '500' MinCapacity: '50' ScheduledActionName: First StartTime: '2019-12-25T12:00:00.000Z' Schedule: 'cron(0 18 * * ? *)'

Declaring a scheduled action for a Spot Fleet

This snippet shows how to create a scheduled action and apply it to an AWS::EC2::SpotFleet resource using the AWS::ApplicationAutoScaling::ScalableTarget resource. It uses the Fn::Join and Ref intrinsic functions to construct the ResourceId property.

JSON

{ "Resources":{ "SpotFleetScalableTarget":{ "Type":"AWS::ApplicationAutoScaling::ScalableTarget", "Properties":{ "MaxCapacity":2, "MinCapacity":1, "RoleARN":{ "Fn::Sub":"arn:aws:iam::${AWS::AccountId}:role/aws-service-role/ec2.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_EC2SpotFleetRequest" }, "ServiceNamespace":"ec2", "ScalableDimension":"ec2:spot-fleet-request:TargetCapacity", "ResourceId":{ "Fn::Join":[ "/", [ "spot-fleet-request", { "Ref":"ECSSpotFleet" } ] ] }, "ScheduledActions":[ { "EndTime":"2019-12-31T12:00:00.000Z", "ScalableTargetAction":{ "MaxCapacity":"20", "MinCapacity":"5" }, "ScheduledActionName":"First", "StartTime":"2019-12-25T12:00:00.000Z", "Schedule":"cron(0 18 * * ? *)" } ] } } } }

YAML

--- Resources: SpotFleetScalableTarget: Type: AWS::ApplicationAutoScaling::ScalableTarget Properties: MaxCapacity: 2 MinCapacity: 1 RoleARN: Fn::Sub: 'arn:aws:iam::${AWS::AccountId}:role/aws-service-role/ec2.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_EC2SpotFleetRequest' ServiceNamespace: ec2 ScalableDimension: 'ec2:spot-fleet-request:TargetCapacity' ResourceId: !Join - / - - spot-fleet-request - !Ref ECSSpotFleet ScheduledActions: - EndTime: '2019-12-31T12:00:00.000Z' ScalableTargetAction: MaxCapacity: '20' MinCapacity: '5' ScheduledActionName: First StartTime: '2019-12-25T12:00:00.000Z' Schedule: 'cron(0 18 * * ? *)'