[ aws . autoscaling ]

put-scaling-policy

Description

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 .

See also: AWS API Documentation

See ‘aws help’ for descriptions of global parameters.

Synopsis

  put-scaling-policy
--auto-scaling-group-name <value>
--policy-name <value>
[--policy-type <value>]
[--adjustment-type <value>]
[--min-adjustment-step <value>]
[--min-adjustment-magnitude <value>]
[--scaling-adjustment <value>]
[--cooldown <value>]
[--metric-aggregation-type <value>]
[--step-adjustments <value>]
[--estimated-instance-warmup <value>]
[--target-tracking-configuration <value>]
[--enabled | --no-enabled]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--cli-auto-prompt <value>]

Options

--auto-scaling-group-name (string)

The name of the Auto Scaling group.

--policy-name (string)

The name of the policy.

--policy-type (string)

One of the following policy types:

  • TargetTrackingScaling

  • StepScaling

  • SimpleScaling (default)

--adjustment-type (string)

Specifies how the scaling adjustment is interpreted (either 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 .

--min-adjustment-step (integer)

Available for backward compatibility. Use MinAdjustmentMagnitude instead.

--min-adjustment-magnitude (integer)

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.

--scaling-adjustment (integer)

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

--cooldown (integer)

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 .

--metric-aggregation-type (string)

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 .

--step-adjustments (list)

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

(structure)

Describes information used to create a step adjustment for a step scaling policy.

For the following examples, suppose that you have an alarm with a breach threshold of 50:

  • To trigger the adjustment when the metric is greater than or equal to 50 and less than 60, specify a lower bound of 0 and an upper bound of 10.

  • To trigger the adjustment when the metric is greater than 40 and less than or equal to 50, specify a lower bound of -10 and an upper bound of 0.

There are a few rules for the step adjustments for your step policy:

  • The ranges of your step adjustments can’t overlap or have a gap.

  • At most, one step adjustment can have a null lower bound. If one step adjustment has a negative lower bound, then there must be a step adjustment with a null lower bound.

  • At most, one step adjustment can have a null upper bound. If one step adjustment has a positive upper bound, then there must be a step adjustment with a null upper bound.

  • The upper and lower bound can’t be null in the same step adjustment.

For more information, see Step Adjustments in the Amazon EC2 Auto Scaling User Guide .

MetricIntervalLowerBound -> (double)

The lower bound for the difference between the alarm threshold and the CloudWatch metric. If the metric value is above the breach threshold, the lower bound is inclusive (the metric must be greater than or equal to the threshold plus the lower bound). Otherwise, it is exclusive (the metric must be greater than the threshold plus the lower bound). A null value indicates negative infinity.

MetricIntervalUpperBound -> (double)

The upper bound for the difference between the alarm threshold and the CloudWatch metric. If the metric value is above the breach threshold, the upper bound is exclusive (the metric must be less than the threshold plus the upper bound). Otherwise, it is inclusive (the metric must be less than or equal to the threshold plus the upper bound). A null value indicates positive infinity.

The upper bound must be greater than the lower bound.

ScalingAdjustment -> (integer)

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.

Shorthand Syntax:

MetricIntervalLowerBound=double,MetricIntervalUpperBound=double,ScalingAdjustment=integer ...

JSON Syntax:

[
  {
    "MetricIntervalLowerBound": double,
    "MetricIntervalUpperBound": double,
    "ScalingAdjustment": integer
  }
  ...
]

--estimated-instance-warmup (integer)

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 .

--target-tracking-configuration (structure)

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 .

For more information, see TargetTrackingConfiguration in the Amazon EC2 Auto Scaling API Reference .

Required if the policy type is TargetTrackingScaling .

PredefinedMetricSpecification -> (structure)

A predefined metric. You must specify either a predefined metric or a customized metric.

PredefinedMetricType -> (string)

The metric type. The following predefined metrics are available:

  • ASGAverageCPUUtilization - Average CPU utilization of the Auto Scaling group.

  • ASGAverageNetworkIn - Average number of bytes received on all network interfaces by the Auto Scaling group.

  • ASGAverageNetworkOut - Average number of bytes sent out on all network interfaces by the Auto Scaling group.

  • ALBRequestCountPerTarget - Number of requests completed per target in an Application Load Balancer target group.

ResourceLabel -> (string)

Identifies the resource associated with the metric type. You can’t specify a resource label unless the metric type is ALBRequestCountPerTarget and there is a target group attached to the Auto Scaling group.

Elastic Load Balancing sends data about your load balancers to Amazon CloudWatch. CloudWatch collects the data and specifies the format to use to access the data. The format is ``app/load-balancer-name /load-balancer-id /targetgroup/target-group-name /target-group-id `` , where

  • ``app/load-balancer-name /load-balancer-id `` is the final portion of the load balancer ARN, and

  • ``targetgroup/target-group-name /target-group-id `` is the final portion of the target group ARN.

To find the ARN for an Application Load Balancer, use the DescribeLoadBalancers API operation. To find the ARN for the target group, use the DescribeTargetGroups API operation.

CustomizedMetricSpecification -> (structure)

A customized metric. You must specify either a predefined metric or a customized metric.

MetricName -> (string)

The name of the metric.

Namespace -> (string)

The namespace of the metric.

Dimensions -> (list)

The dimensions of the metric.

Conditional: If you published your metric with dimensions, you must specify the same dimensions in your scaling policy.

(structure)

Describes the dimension of a metric.

Name -> (string)

The name of the dimension.

Value -> (string)

The value of the dimension.

Statistic -> (string)

The statistic of the metric.

Unit -> (string)

The unit of the metric.

TargetValue -> (double)

The target value for the metric.

DisableScaleIn -> (boolean)

Indicates whether scaling in by the target tracking scaling policy is disabled. If scaling in is disabled, the target tracking scaling policy doesn’t remove instances from the Auto Scaling group. Otherwise, the target tracking scaling policy can remove instances from the Auto Scaling group. The default is false .

JSON Syntax:

{
  "PredefinedMetricSpecification": {
    "PredefinedMetricType": "ASGAverageCPUUtilization"|"ASGAverageNetworkIn"|"ASGAverageNetworkOut"|"ALBRequestCountPerTarget",
    "ResourceLabel": "string"
  },
  "CustomizedMetricSpecification": {
    "MetricName": "string",
    "Namespace": "string",
    "Dimensions": [
      {
        "Name": "string",
        "Value": "string"
      }
      ...
    ],
    "Statistic": "Average"|"Minimum"|"Maximum"|"SampleCount"|"Sum",
    "Unit": "string"
  },
  "TargetValue": double,
  "DisableScaleIn": true|false
}

--enabled | --no-enabled (boolean)

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 .

--cli-input-json | --cli-input-yaml (string) Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml.

--generate-cli-skeleton (string) Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input, prints a sample input JSON that can be used as an argument for --cli-input-json. Similarly, if provided yaml-input it will print a sample input YAML that can be used with --cli-input-yaml. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command.

--cli-auto-prompt (boolean) Automatically prompt for CLI input parameters.

See ‘aws help’ for descriptions of global parameters.

Examples

To add a scaling policy to an Auto Scaling group

The following put-scaling-policy example applies a target tracking scaling policy to the specified Auto Scaling group. The output contains the ARNs and names of the two CloudWatch alarms created on your behalf.

aws autoscaling put-scaling-policy --policy-name alb1000-target-tracking-scaling-policy \
--auto-scaling-group-name my-asg --policy-type TargetTrackingScaling \
--target-tracking-configuration file://config.json

This example assumes that you have a config.json file in the current directory with the following contents:

{
     "TargetValue": 1000.0,
     "PredefinedMetricSpecification": {
          "PredefinedMetricType": "ALBRequestCountPerTarget",
          "ResourceLabel": "app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d"
     }
}

Output:

{
     "PolicyARN": "arn:aws:autoscaling:region:account-id:scalingPolicy:228f02c2-c665-4bfd-aaac-8b04080bea3c:autoScalingGroupName/my-asg:policyName/alb1000-target-tracking-scaling-policy",
     "Alarms": [
         {
             "AlarmARN": "arn:aws:cloudwatch:region:account-id:alarm:TargetTracking-my-asg-AlarmHigh-fc0e4183-23ac-497e-9992-691c9980c38e",
             "AlarmName": "TargetTracking-my-asg-AlarmHigh-fc0e4183-23ac-497e-9992-691c9980c38e"
         },
         {
             "AlarmARN": "arn:aws:cloudwatch:region:account-id:alarm:TargetTracking-my-asg-AlarmLow-61a39305-ed0c-47af-bd9e-471a352ee1a2",
             "AlarmName": "TargetTracking-my-asg-AlarmLow-61a39305-ed0c-47af-bd9e-471a352ee1a2"
         }
     ]
 }

For more information, see Example Scaling Policies for the AWS Command Line Interface (AWS CLI) in the Amazon EC2 Auto Scaling User Guide.

Output

PolicyARN -> (string)

The Amazon Resource Name (ARN) of the policy.

Alarms -> (list)

The CloudWatch alarms created for the target tracking scaling policy.

(structure)

Describes an alarm.

AlarmName -> (string)

The name of the alarm.

AlarmARN -> (string)

The Amazon Resource Name (ARN) of the alarm.