Table Of Contents

Feedback

User Guide

First time using the AWS CLI? See the User Guide for help getting started.

Note: You are viewing the documentation for an older major version of the AWS CLI (version 1).

AWS CLI version 2, the latest major version of AWS CLI, is now stable and recommended for general use. To view this page for the AWS CLI version 2, click here. For more information see the AWS CLI version 2 installation instructions and migration guide.

[ 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 <value>]
[--generate-cli-skeleton <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)

The policy type. The valid values are SimpleScaling , StepScaling , and TargetTrackingScaling . If the policy type is null, the value is treated as SimpleScaling .

--adjustment-type (string)

Specifies whether the ScalingAdjustment parameter is an absolute number or a percentage of the current capacity. The valid values are ChangeInCapacity , ExactCapacity , and PercentChangeInCapacity .

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 .

--min-adjustment-step (integer)

Available for backward compatibility. Use MinAdjustmentMagnitude instead.

--min-adjustment-magnitude (integer)

The minimum value to scale by when scaling by percentages. 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 and the adjustment type is PercentChangeInCapacity . For more information, see Scaling Adjustment Types in the Amazon EC2 Auto Scaling User Guide .

--scaling-adjustment (integer)

The amount by which a simple scaling policy scales the Auto Scaling group in response to an alarm breach. The adjustment is based on the value that you specified in the AdjustmentType parameter (either an absolute number or a percentage). A positive value adds to the current capacity and a negative value subtracts from the current capacity. For exact capacity, you must specify a positive value.

Conditional: If you specify SimpleScaling for the policy type, you must specify this parameter. (Not used with any other policy type.)

--cooldown (integer)

The amount of time, in seconds, after a scaling activity completes before any further dynamic scaling activities can start. If this parameter is not specified, the default cooldown period for the group applies.

Valid only if the policy type is SimpleScaling . For more information, see Scaling Cooldowns 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.

Conditional: If you specify StepScaling for the policy type, you must specify this parameter. (Not used with any other policy type.)

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. The default is to use the value specified for the default cooldown period for the group.

Valid only if the policy type is StepScaling or TargetTrackingScaling .

--target-tracking-configuration (structure)

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

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

Conditional: If you specify TargetTrackingScaling for the policy type, you must specify this parameter. (Not used with any other policy type.)

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 (string) Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, the CLI 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.

--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. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command.

See 'aws help' for descriptions of global parameters.

Examples

To add a scaling policy to an Auto Scaling group

This example adds a simple scaling policy to the specified Auto Scaling group:

aws autoscaling put-scaling-policy --auto-scaling-group-name my-auto-scaling-group --policy-name ScaleIn --scaling-adjustment -1 --adjustment-type ChangeInCapacity

To change the size of the Auto Scaling group by a specific number of instances, set the adjustment-type parameter to PercentChangeInCapacity. Then, assign a value to the min-adjustment-step parameter, where the value represents the number of instances the policy adds or removes from the Auto Scaling group:

aws autoscaling put-scaling-policy --auto-scaling-group-name my-auto-scaling-group --policy-name ScalePercentChange --scaling-adjustment 25 --adjustment-type PercentChangeInCapacity --cooldown 60 --min-adjustment-step 2

The output includes the ARN of the policy. The following is example output:

{
    "PolicyARN": "arn:aws:autoscaling:us-west-2:123456789012:scalingPolicy:2233f3d7-6290-403b-b632-93c553560106:autoScalingGroupName/my-auto-scaling-group:policyName/ScaleIn"
}

For more information, see Dynamic Scaling 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.