Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::ApplicationAutoScaling::ScalingPolicy

The AWS::ApplicationAutoScaling::ScalingPolicy resource defines an Application Auto Scaling scaling policy that Application Auto Scaling uses to adjust your application resources.

Syntax

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

JSON

Copy
{ "Type" : "AWS::ApplicationAutoScaling::ScalingPolicy", "Properties" : { "PolicyName" : String, "PolicyType" : String, "ResourceId" : String, "ScalableDimension" : String, "ScalingTargetId" : String, "ServiceNamespace" : String, "StepScalingPolicyConfiguration" : StepScalingPolicyConfiguration } }

YAML

Copy
Type" : "AWS::ApplicationAutoScaling::ScalingPolicy" Properties: PolicyName: String PolicyType: String ResourceId: String ScalableDimension: String ScalingTargetId: String ServiceNamespace: String StepScalingPolicyConfiguration: StepScalingPolicyConfiguration

Properties

PolicyName

A name for the scaling policy.

Required: Yes

Type: String

Update requires: Replacement

PolicyType

An Application Auto Scaling policy type. For valid values, see the PolicyType parameter for the PutScalingPolicy action in the Application Auto Scaling API Reference.

Required: Yes

Type: String

Update requires: No interruption

ResourceId

The unique resource identifier for the scalable target that this scaling policy applies to. For more information, see the ResourceId parameter for the PutScalingPolicy action in the Application Auto Scaling API Reference.

Required: Conditional. You must specify either the ScalingTargetId property or the ResourceId, ScalableDimension, and ServiceNamespace properties. If you specify the ResourceId, ScalableDimension, and ServiceNamespace properties, don't specify the ScalingTargetId property.

Type: String

Update requires: Replacement

ScalableDimension

The scalable dimension of the scalable target that this scaling policy applies to. The scalable dimension contains the service namespace, resource type, and scaling property, such as ecs:service:DesiredCount for the desired task count of an Amazon ECS service.

Required: Conditional. You must specify either the ScalingTargetId property or the ResourceId, ScalableDimension, and ServiceNamespace properties. If you specify the ResourceId, ScalableDimension, and ServiceNamespace properties, don't specify the ScalingTargetId property.

Type: String

Update requires: Replacement

ServiceNamespace

The AWS service namespace of the scalable target that this scaling policy applies to. For a list of service namespaces, see AWS Service Namespaces in the AWS General Reference.

Required: Conditional. You must specify either the ScalingTargetId property or the ResourceId, ScalableDimension, and ServiceNamespace properties. If you specify the ResourceId, ScalableDimension, and ServiceNamespace properties, don't specify the ScalingTargetId property.

Type: String

Update requires: Replacement

ScalingTargetId

The AWS CloudFormation-generated ID of an Application Auto Scaling scalable target. For more information about the ID, see the Return Value section of the AWS::ApplicationAutoScaling::ScalableTarget resource.

Required: Conditional. You must specify either the ScalingTargetId property or the ResourceId, ScalableDimension, and ServiceNamespace properties. If you specify this property, don't specify the ResourceId, ScalableDimension, and ServiceNamespace properties.

Type: String

Update requires: Replacement

StepScalingPolicyConfiguration

A step policy that configures when Application Auto Scaling scales resources up or down, and by how much.

Required: No

Type: Application Auto Scaling ScalingPolicy StepScalingPolicyConfiguration

Update requires: No interruption

Return Value

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the Application Auto Scaling scaling policy Amazon Resource Name (ARN), such as arn:aws:autoscaling:us-east-1:123456789012:scalingPolicy:12ab3c4d-56789-0ef1-2345-6ghi7jk8lm90:resource/ecs/service/ecsStack-MyECSCluster-AB12CDE3F4GH/ecsStack-MyECSService-AB12CDE3F4GH:policyName/MyStepPolicy.

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

Example

The following example creates an Application Auto Scaling scaling policy with a step policy configuration. When an associated alarm is breached, the policy increases the desired count of the scalable target by 200%, with a cooldown period of 60 seconds.

JSON

Copy
"scalingPolicy" : { "Type" : "AWS::ApplicationAutoScaling::ScalingPolicy", "Properties" : { "PolicyName" : "AStepPolicy", "PolicyType" : "StepScaling", "ScalingTargetId" : {"Ref": "scalableTarget"}, "StepScalingPolicyConfiguration" : { "AdjustmentType" : "PercentChangeInCapacity", "Cooldown" : 60, "MetricAggregationType" : "Average", "StepAdjustments" : [{ "MetricIntervalLowerBound" : 0, "ScalingAdjustment" : 200 }] } } }

YAML

Copy
scalingPolicy: Type: AWS::ApplicationAutoScaling::ScalingPolicy Properties: PolicyName: AStepPolicy PolicyType: StepScaling ScalingTargetId: Ref: scalableTarget StepScalingPolicyConfiguration: AdjustmentType: PercentChangeInCapacity Cooldown: 60 MetricAggregationType: Average StepAdjustments: - MetricIntervalLowerBound: 0 ScalingAdjustment: 200