Auto Scaling

2020/02/18 - Auto Scaling - 2 updated api methods

Changes  Update autoscaling client to latest version

DescribePolicies (updated) Link ¶
Changes (response)
{'ScalingPolicies': {'Enabled': 'boolean'}}

Describes the policies for the specified Auto Scaling group.

See also: AWS API Documentation

Request Syntax

client.describe_policies(
    AutoScalingGroupName='string',
    PolicyNames=[
        'string',
    ],
    PolicyTypes=[
        'string',
    ],
    NextToken='string',
    MaxRecords=123
)
type AutoScalingGroupName:

string

param AutoScalingGroupName:

The name of the Auto Scaling group.

type PolicyNames:

list

param PolicyNames:

The names of one or more policies. If you omit this parameter, all policies are described. If a group name is provided, the results are limited to that group. This list is limited to 50 items. If you specify an unknown policy name, it is ignored with no error.

  • (string) --

type PolicyTypes:

list

param PolicyTypes:

One or more policy types. The valid values are SimpleScaling, StepScaling, and TargetTrackingScaling.

  • (string) --

type NextToken:

string

param NextToken:

The token for the next set of items to return. (You received this token from a previous call.)

type MaxRecords:

integer

param MaxRecords:

The maximum number of items to be returned with each call. The default value is 50 and the maximum value is 100.

rtype:

dict

returns:

Response Syntax

{
    'ScalingPolicies': [
        {
            'AutoScalingGroupName': 'string',
            'PolicyName': 'string',
            'PolicyARN': 'string',
            'PolicyType': 'string',
            'AdjustmentType': 'string',
            'MinAdjustmentStep': 123,
            'MinAdjustmentMagnitude': 123,
            'ScalingAdjustment': 123,
            'Cooldown': 123,
            'StepAdjustments': [
                {
                    'MetricIntervalLowerBound': 123.0,
                    'MetricIntervalUpperBound': 123.0,
                    'ScalingAdjustment': 123
                },
            ],
            'MetricAggregationType': 'string',
            'EstimatedInstanceWarmup': 123,
            'Alarms': [
                {
                    'AlarmName': 'string',
                    'AlarmARN': 'string'
                },
            ],
            'TargetTrackingConfiguration': {
                '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': 123.0,
                'DisableScaleIn': True|False
            },
            'Enabled': True|False
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • ScalingPolicies (list) --

      The scaling policies.

      • (dict) --

        Describes a scaling policy.

        • AutoScalingGroupName (string) --

          The name of the Auto Scaling group.

        • PolicyName (string) --

          The name of the scaling policy.

        • PolicyARN (string) --

          The Amazon Resource Name (ARN) of the policy.

        • PolicyType (string) --

          The policy type. The valid values are SimpleScaling, StepScaling, and TargetTrackingScaling.

        • AdjustmentType (string) --

          The adjustment type, which specifies how ScalingAdjustment is interpreted. The valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.

        • MinAdjustmentStep (integer) --

          Available for backward compatibility. Use MinAdjustmentMagnitude instead.

        • MinAdjustmentMagnitude (integer) --

          The minimum number of instances to scale. If the value of AdjustmentType is PercentChangeInCapacity, the scaling policy changes the DesiredCapacity of the Auto Scaling group by at least this many instances. Otherwise, the error is ValidationError.

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

        • Cooldown (integer) --

          The amount of time, in seconds, after a scaling activity completes before any further dynamic scaling activities can start.

        • StepAdjustments (list) --

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

          • (dict) --

            Describes an adjustment based on the difference between the value of the aggregated CloudWatch metric and the breach threshold that you've defined for the alarm. Used in combination with PutScalingPolicy.

            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.

            • MetricIntervalLowerBound (float) --

              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 (float) --

              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.

        • MetricAggregationType (string) --

          The aggregation type for the CloudWatch metrics. The valid values are Minimum, Maximum, and Average.

        • EstimatedInstanceWarmup (integer) --

          The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics.

        • Alarms (list) --

          The CloudWatch alarms related to the policy.

          • (dict) --

            Describes an alarm.

            • AlarmName (string) --

              The name of the alarm.

            • AlarmARN (string) --

              The Amazon Resource Name (ARN) of the alarm.

        • TargetTrackingConfiguration (dict) --

          A target tracking scaling policy.

          • PredefinedMetricSpecification (dict) --

            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.

              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.

          • CustomizedMetricSpecification (dict) --

            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.

              • (dict) --

                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 (float) --

            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.

        • Enabled (boolean) --

    • NextToken (string) --

      A string that indicates that the response contains more items than can be returned in a single response. To receive additional items, specify this string for the NextToken value when requesting the next set of items. This value is null when there are no more items to return.

PutScalingPolicy (updated) Link ¶
Changes (request)
{'Enabled': 'boolean'}

Creates or updates a scaling policy for an Auto Scaling group. To update an existing scaling policy, use the existing policy name and set the parameters to change. Any existing parameter not changed in an update to an existing policy is not changed in this update request.

For more information about using scaling policies to scale your Auto Scaling group automatically, see Dynamic Scaling in the Amazon EC2 Auto Scaling User Guide.

See also: AWS API Documentation

Request Syntax

client.put_scaling_policy(
    AutoScalingGroupName='string',
    PolicyName='string',
    PolicyType='string',
    AdjustmentType='string',
    MinAdjustmentStep=123,
    MinAdjustmentMagnitude=123,
    ScalingAdjustment=123,
    Cooldown=123,
    MetricAggregationType='string',
    StepAdjustments=[
        {
            'MetricIntervalLowerBound': 123.0,
            'MetricIntervalUpperBound': 123.0,
            'ScalingAdjustment': 123
        },
    ],
    EstimatedInstanceWarmup=123,
    TargetTrackingConfiguration={
        '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': 123.0,
        'DisableScaleIn': True|False
    },
    Enabled=True|False
)
type AutoScalingGroupName:

string

param AutoScalingGroupName:

[REQUIRED]

The name of the Auto Scaling group.

type PolicyName:

string

param PolicyName:

[REQUIRED]

The name of the policy.

type PolicyType:

string

param PolicyType:

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

type AdjustmentType:

string

param AdjustmentType:

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.

type MinAdjustmentStep:

integer

param MinAdjustmentStep:

Available for backward compatibility. Use MinAdjustmentMagnitude instead.

type MinAdjustmentMagnitude:

integer

param MinAdjustmentMagnitude:

The minimum number of instances to scale. If the value of AdjustmentType is PercentChangeInCapacity, the scaling policy changes the DesiredCapacity of the Auto Scaling group by at least this many instances. Otherwise, the error is ValidationError.

This property replaces the MinAdjustmentStep property. 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 SimpleScaling or StepScaling.

type ScalingAdjustment:

integer

param ScalingAdjustment:

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

type Cooldown:

integer

param Cooldown:

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.

type MetricAggregationType:

string

param 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 StepAdjustments:

list

param StepAdjustments:

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

  • (dict) --

    Describes an adjustment based on the difference between the value of the aggregated CloudWatch metric and the breach threshold that you've defined for the alarm. Used in combination with PutScalingPolicy.

    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.

    • MetricIntervalLowerBound (float) --

      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 (float) --

      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) -- [REQUIRED]

      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.

type EstimatedInstanceWarmup:

integer

param EstimatedInstanceWarmup:

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.

type TargetTrackingConfiguration:

dict

param TargetTrackingConfiguration:

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

  • PredefinedMetricSpecification (dict) --

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

    • PredefinedMetricType (string) -- [REQUIRED]

      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.

      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.

  • CustomizedMetricSpecification (dict) --

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

    • MetricName (string) -- [REQUIRED]

      The name of the metric.

    • Namespace (string) -- [REQUIRED]

      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.

      • (dict) --

        Describes the dimension of a metric.

        • Name (string) -- [REQUIRED]

          The name of the dimension.

        • Value (string) -- [REQUIRED]

          The value of the dimension.

    • Statistic (string) -- [REQUIRED]

      The statistic of the metric.

    • Unit (string) --

      The unit of the metric.

  • TargetValue (float) -- [REQUIRED]

    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.

type Enabled:

boolean

param Enabled:

rtype:

dict

returns:

Response Syntax

{
    'PolicyARN': 'string',
    'Alarms': [
        {
            'AlarmName': 'string',
            'AlarmARN': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    Contains the output of PutScalingPolicy.

    • PolicyARN (string) --

      The Amazon Resource Name (ARN) of the policy.

    • Alarms (list) --

      The CloudWatch alarms created for the target tracking scaling policy.

      • (dict) --

        Describes an alarm.

        • AlarmName (string) --

          The name of the alarm.

        • AlarmARN (string) --

          The Amazon Resource Name (ARN) of the alarm.