PutScalingPolicy - Amazon EC2 Auto Scaling

PutScalingPolicy

Creates or updates a scaling policy for an Auto Scaling group.

For more information about using scaling policies to scale your Auto Scaling group, see Target Tracking Scaling Policies and Step and Simple Scaling Policies in the Amazon EC2 Auto Scaling User Guide.

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

AdjustmentType

Specifies how the scaling adjustment is interpreted (for example, an absolute number or a percentage). The valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.

Required if the policy type is StepScaling or SimpleScaling. For more information, see Scaling Adjustment Types in the Amazon EC2 Auto Scaling User Guide.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 255.

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Required: No

AutoScalingGroupName

The name of the Auto Scaling group.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1600.

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Required: Yes

Cooldown

The duration of the policy's cooldown period, in seconds. When a cooldown period is specified here, it overrides the default cooldown period defined for the Auto Scaling group.

Valid only if the policy type is SimpleScaling. For more information, see Scaling Cooldowns for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.

Type: Integer

Required: No

Enabled

Indicates whether the scaling policy is enabled or disabled. The default is enabled. For more information, see Disabling a Scaling Policy for an Auto Scaling Group in the Amazon EC2 Auto Scaling User Guide.

Type: Boolean

Required: No

EstimatedInstanceWarmup

The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics. If not provided, the default is to use the value from the default cooldown period for the Auto Scaling group.

Valid only if the policy type is TargetTrackingScaling or StepScaling.

Type: Integer

Required: No

MetricAggregationType

The aggregation type for the CloudWatch metrics. The valid values are Minimum, Maximum, and Average. If the aggregation type is null, the value is treated as Average.

Valid only if the policy type is StepScaling.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 32.

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Required: No

MinAdjustmentMagnitude

The minimum value to scale by when the adjustment type is PercentChangeInCapacity. For example, suppose that you create a step scaling policy to scale out an Auto Scaling group by 25 percent and you specify a MinAdjustmentMagnitude of 2. If the group has 4 instances and the scaling policy is performed, 25 percent of 4 is 1. However, because you specified a MinAdjustmentMagnitude of 2, Amazon EC2 Auto Scaling scales out the group by 2 instances.

Valid only if the policy type is StepScaling or SimpleScaling. For more information, see Scaling Adjustment Types in the Amazon EC2 Auto Scaling User Guide.

Note

Some Auto Scaling groups use instance weights. In this case, set the MinAdjustmentMagnitude to a value that is at least as large as your largest instance weight.

Type: Integer

Required: No

MinAdjustmentStep

This parameter has been deprecated.

Available for backward compatibility. Use MinAdjustmentMagnitude instead.

Type: Integer

Required: No

PolicyName

The name of the policy.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 255.

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Required: Yes

PolicyType

One of the following policy types:

  • TargetTrackingScaling

  • StepScaling

  • SimpleScaling (default)

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Required: No

ScalingAdjustment

The amount by which to scale, based on the specified adjustment type. A positive value adds to the current capacity while a negative number removes from the current capacity. For exact capacity, you must specify a positive value.

Required if the policy type is SimpleScaling. (Not used with any other policy type.)

Type: Integer

Required: No

StepAdjustments.member.N

A set of adjustments that enable you to scale based on the size of the alarm breach.

Required if the policy type is StepScaling. (Not used with any other policy type.)

Type: Array of StepAdjustment objects

Required: No

TargetTrackingConfiguration

A target tracking scaling policy. Includes support for predefined or customized metrics.

The following predefined metrics are available:

  • ASGAverageCPUUtilization

  • ASGAverageNetworkIn

  • ASGAverageNetworkOut

  • ALBRequestCountPerTarget

If you specify ALBRequestCountPerTarget for the metric, you must specify the ResourceLabel parameter with the PredefinedMetricSpecification.

Required if the policy type is TargetTrackingScaling.

Type: TargetTrackingConfiguration object

Required: No

Response Elements

The following elements are returned by the service.

Alarms.member.N

The CloudWatch alarms created for the target tracking scaling policy.

Type: Array of Alarm objects

PolicyARN

The Amazon Resource Name (ARN) of the policy.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1600.

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Errors

For information about the errors that are common to all actions, see Common Errors.

LimitExceeded

You have already reached a limit for your Amazon EC2 Auto Scaling resources (for example, Auto Scaling groups, launch configurations, or lifecycle hooks). For more information, see DescribeAccountLimits.

HTTP Status Code: 400

ResourceContention

You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).

HTTP Status Code: 500

ServiceLinkedRoleFailure

The service-linked role is not yet ready for use.

HTTP Status Code: 500

Example

Sample Request

https://autoscaling.amazonaws.com/?Action=PutScalingPolicy &AutoScalingGroupName=my-asg &PolicyName=alb1000-target-tracking-scaling-policy &PolicyType=TargetTrackingScaling &TargetTrackingConfiguration.TargetValue=1000.0 &TargetTrackingConfiguration.PredefinedMetricSpecification.PredefinedMetricType=ALBRequestCountPerTarget &TargetTrackingConfiguration.PredefinedMetricSpecification.ResourceLabel=app%2FEC2Co-EcsEl-1TKLTMITMM0EO%2Ff37c06a68c1748aa%2Ftargetgroup%2FEC2Co-Defau-LDNM7Q3ZH1ZN%2F6d4ea56ca2d6a18d &Version=2011-01-01 &AUTHPARAMS

Sample Response

<PutScalingPolicyResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/"> <PutScalingPolicyResult> <PolicyARN>arn:aws:autoscaling:us-east-1:123456789012:scalingPolicy:228f02c2-c665-4bfd-aaac-8b04080bea3c:autoScalingGroupName/my-asg:policyName/alb1000-target-tracking-scaling-policy</PolicyARN> <Alarms> <member> <AlarmName>TargetTracking-my-asg-AlarmHigh-fc0e4183-23ac-497e-9992-691c9980c38e</AlarmName> <AlarmARN>arn:aws:cloudwatch:us-east-1:123456789012:alarm:TargetTracking-my-asg-AlarmHigh-fc0e4183-23ac-497e-9992-691c9980c38e</AlarmARN> </member> <member> <AlarmName>TargetTracking-my-asg-AlarmLow-61a39305-ed0c-47af-bd9e-471a352ee1a2</AlarmName> <AlarmARN>arn:aws:cloudwatch:us-east-1:123456789012:alarm:TargetTracking-my-asg-AlarmLow-61a39305-ed0c-47af-bd9e-471a352ee1a2</AlarmARN> </member> </Alarms> </PutScalingPolicyResult> <ResponseMetadata> <RequestId>7c6e177f-f082-11e1-ac58-3714bEXAMPLE</RequestId> </ResponseMetadata> </PutScalingPolicyResponse>

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: