Auto Scaling

2021/05/19 - Auto Scaling - 1 new 3 updated api methods

Changes  With this release, customers can easily use Predictive Scaling as a policy directly through Amazon EC2 Auto Scaling configurations to proactively scale their applications ahead of predicted demand.

GetPredictiveScalingForecast (new) Link ¶

Retrieves the forecast data for a predictive scaling policy.

Load forecasts are predictions of the hourly load values using historical load data from CloudWatch and an analysis of historical trends. Capacity forecasts are represented as predicted values for the minimum capacity that is needed on an hourly basis, based on the hourly load forecast.

A minimum of 24 hours of data is required to create the initial forecasts. However, having a full 14 days of historical data results in more accurate forecasts.

For more information, see Predictive scaling for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide .

See also: AWS API Documentation

Request Syntax

client.get_predictive_scaling_forecast(
    AutoScalingGroupName='string',
    PolicyName='string',
    StartTime=datetime(2015, 1, 1),
    EndTime=datetime(2015, 1, 1)
)
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 StartTime

datetime

param StartTime

[REQUIRED]

The inclusive start time of the time range for the forecast data to get. At most, the date and time can be one year before the current date and time.

type EndTime

datetime

param EndTime

[REQUIRED]

The exclusive end time of the time range for the forecast data to get. The maximum time duration between the start and end time is 30 days.

Although this parameter can accept a date and time that is more than two days in the future, the availability of forecast data has limits. Amazon EC2 Auto Scaling only issues forecasts for periods of two days in advance.

rtype

dict

returns

Response Syntax

{
    'LoadForecast': [
        {
            'Timestamps': [
                datetime(2015, 1, 1),
            ],
            'Values': [
                123.0,
            ],
            'MetricSpecification': {
                'TargetValue': 123.0,
                'PredefinedMetricPairSpecification': {
                    'PredefinedMetricType': 'ASGCPUUtilization'|'ASGNetworkIn'|'ASGNetworkOut'|'ALBRequestCount',
                    'ResourceLabel': 'string'
                },
                'PredefinedScalingMetricSpecification': {
                    'PredefinedMetricType': 'ASGAverageCPUUtilization'|'ASGAverageNetworkIn'|'ASGAverageNetworkOut'|'ALBRequestCountPerTarget',
                    'ResourceLabel': 'string'
                },
                'PredefinedLoadMetricSpecification': {
                    'PredefinedMetricType': 'ASGTotalCPUUtilization'|'ASGTotalNetworkIn'|'ASGTotalNetworkOut'|'ALBTargetGroupRequestCount',
                    'ResourceLabel': 'string'
                }
            }
        },
    ],
    'CapacityForecast': {
        'Timestamps': [
            datetime(2015, 1, 1),
        ],
        'Values': [
            123.0,
        ]
    },
    'UpdateTime': datetime(2015, 1, 1)
}

Response Structure

  • (dict) --

    • LoadForecast (list) --

      The load forecast.

      • (dict) --

        A GetPredictiveScalingForecast call returns the load forecast for a predictive scaling policy. This structure includes the data points for that load forecast, along with the timestamps of those data points and the metric specification.

        • Timestamps (list) --

          The time stamps for the data points, in UTC format.

          • (datetime) --

        • Values (list) --

          The values of the data points.

          • (float) --

        • MetricSpecification (dict) --

          The metric specification for the load forecast.

          • TargetValue (float) --

            Specifies the target utilization.

          • PredefinedMetricPairSpecification (dict) --

            The metric pair specification from which Amazon EC2 Auto Scaling determines the appropriate scaling metric and load metric to use.

            • PredefinedMetricType (string) --

              Indicates which metrics to use. There are two different types of metrics for each metric type: one is a load metric and one is a scaling metric. For example, if the metric type is ASGCPUUtilization , the Auto Scaling group's total CPU metric is used as the load metric, and the average CPU metric is used for the scaling metric.

            • ResourceLabel (string) --

              A label that uniquely identifies a specific Application Load Balancer target group from which to determine the request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.

              You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:

              app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d .

              Where:

              • app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN

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

          • PredefinedScalingMetricSpecification (dict) --

            The scaling metric specification.

            • PredefinedMetricType (string) --

              The metric type.

            • ResourceLabel (string) --

              A label that uniquely identifies a specific Application Load Balancer target group from which to determine the request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.

              You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:

              app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d .

              Where:

              • app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN

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

          • PredefinedLoadMetricSpecification (dict) --

            The load metric specification.

            • PredefinedMetricType (string) --

              The metric type.

            • ResourceLabel (string) --

              A label that uniquely identifies a specific Application Load Balancer target group from which to determine the request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.

              You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:

              app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d .

              Where:

              • app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN

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

    • CapacityForecast (dict) --

      The capacity forecast.

      • Timestamps (list) --

        The time stamps for the data points, in UTC format.

        • (datetime) --

      • Values (list) --

        The values of the data points.

        • (float) --

    • UpdateTime (datetime) --

      The time the forecast was made.

DescribeAutoScalingGroups (updated) Link ¶
Changes (response)
{'AutoScalingGroups': {'PredictedCapacity': 'integer'}}

Describes one or more Auto Scaling groups.

This operation returns information about instances in Auto Scaling groups. To retrieve information about the instances in a warm pool, you must call the DescribeWarmPool API.

See also: AWS API Documentation

Request Syntax

client.describe_auto_scaling_groups(
    AutoScalingGroupNames=[
        'string',
    ],
    NextToken='string',
    MaxRecords=123
)
type AutoScalingGroupNames

list

param AutoScalingGroupNames

The names of the Auto Scaling groups. By default, you can only specify up to 50 names. You can optionally increase this limit using the MaxRecords parameter.

If you omit this parameter, all Auto Scaling groups are described.

  • (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 return with this call. The default value is 50 and the maximum value is 100 .

rtype

dict

returns

Response Syntax

{
    'AutoScalingGroups': [
        {
            'AutoScalingGroupName': 'string',
            'AutoScalingGroupARN': 'string',
            'LaunchConfigurationName': 'string',
            'LaunchTemplate': {
                'LaunchTemplateId': 'string',
                'LaunchTemplateName': 'string',
                'Version': 'string'
            },
            'MixedInstancesPolicy': {
                'LaunchTemplate': {
                    'LaunchTemplateSpecification': {
                        'LaunchTemplateId': 'string',
                        'LaunchTemplateName': 'string',
                        'Version': 'string'
                    },
                    'Overrides': [
                        {
                            'InstanceType': 'string',
                            'WeightedCapacity': 'string',
                            'LaunchTemplateSpecification': {
                                'LaunchTemplateId': 'string',
                                'LaunchTemplateName': 'string',
                                'Version': 'string'
                            }
                        },
                    ]
                },
                'InstancesDistribution': {
                    'OnDemandAllocationStrategy': 'string',
                    'OnDemandBaseCapacity': 123,
                    'OnDemandPercentageAboveBaseCapacity': 123,
                    'SpotAllocationStrategy': 'string',
                    'SpotInstancePools': 123,
                    'SpotMaxPrice': 'string'
                }
            },
            'MinSize': 123,
            'MaxSize': 123,
            'DesiredCapacity': 123,
            'PredictedCapacity': 123,
            'DefaultCooldown': 123,
            'AvailabilityZones': [
                'string',
            ],
            'LoadBalancerNames': [
                'string',
            ],
            'TargetGroupARNs': [
                'string',
            ],
            'HealthCheckType': 'string',
            'HealthCheckGracePeriod': 123,
            'Instances': [
                {
                    'InstanceId': 'string',
                    'InstanceType': 'string',
                    'AvailabilityZone': 'string',
                    'LifecycleState': 'Pending'|'Pending:Wait'|'Pending:Proceed'|'Quarantined'|'InService'|'Terminating'|'Terminating:Wait'|'Terminating:Proceed'|'Terminated'|'Detaching'|'Detached'|'EnteringStandby'|'Standby'|'Warmed:Pending'|'Warmed:Pending:Wait'|'Warmed:Pending:Proceed'|'Warmed:Terminating'|'Warmed:Terminating:Wait'|'Warmed:Terminating:Proceed'|'Warmed:Terminated'|'Warmed:Stopped'|'Warmed:Running',
                    'HealthStatus': 'string',
                    'LaunchConfigurationName': 'string',
                    'LaunchTemplate': {
                        'LaunchTemplateId': 'string',
                        'LaunchTemplateName': 'string',
                        'Version': 'string'
                    },
                    'ProtectedFromScaleIn': True|False,
                    'WeightedCapacity': 'string'
                },
            ],
            'CreatedTime': datetime(2015, 1, 1),
            'SuspendedProcesses': [
                {
                    'ProcessName': 'string',
                    'SuspensionReason': 'string'
                },
            ],
            'PlacementGroup': 'string',
            'VPCZoneIdentifier': 'string',
            'EnabledMetrics': [
                {
                    'Metric': 'string',
                    'Granularity': 'string'
                },
            ],
            'Status': 'string',
            'Tags': [
                {
                    'ResourceId': 'string',
                    'ResourceType': 'string',
                    'Key': 'string',
                    'Value': 'string',
                    'PropagateAtLaunch': True|False
                },
            ],
            'TerminationPolicies': [
                'string',
            ],
            'NewInstancesProtectedFromScaleIn': True|False,
            'ServiceLinkedRoleARN': 'string',
            'MaxInstanceLifetime': 123,
            'CapacityRebalance': True|False,
            'WarmPoolConfiguration': {
                'MaxGroupPreparedCapacity': 123,
                'MinSize': 123,
                'PoolState': 'Stopped'|'Running',
                'Status': 'PendingDelete'
            },
            'WarmPoolSize': 123
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • AutoScalingGroups (list) --

      The groups.

      • (dict) --

        Describes an Auto Scaling group.

        • AutoScalingGroupName (string) --

          The name of the Auto Scaling group.

        • AutoScalingGroupARN (string) --

          The Amazon Resource Name (ARN) of the Auto Scaling group.

        • LaunchConfigurationName (string) --

          The name of the associated launch configuration.

        • LaunchTemplate (dict) --

          The launch template for the group.

          • LaunchTemplateId (string) --

            The ID of the launch template. To get the template ID, use the Amazon EC2 DescribeLaunchTemplates API operation. New launch templates can be created using the Amazon EC2 CreateLaunchTemplate API.

            Conditional: You must specify either a LaunchTemplateId or a LaunchTemplateName .

          • LaunchTemplateName (string) --

            The name of the launch template. To get the template name, use the Amazon EC2 DescribeLaunchTemplates API operation. New launch templates can be created using the Amazon EC2 CreateLaunchTemplate API.

            Conditional: You must specify either a LaunchTemplateId or a LaunchTemplateName .

          • Version (string) --

            The version number, $Latest , or $Default . To get the version number, use the Amazon EC2 DescribeLaunchTemplateVersions API operation. New launch template versions can be created using the Amazon EC2 CreateLaunchTemplateVersion API. If the value is $Latest , Amazon EC2 Auto Scaling selects the latest version of the launch template when launching instances. If the value is $Default , Amazon EC2 Auto Scaling selects the default version of the launch template when launching instances. The default value is $Default .

        • MixedInstancesPolicy (dict) --

          The mixed instances policy for the group.

          • LaunchTemplate (dict) --

            Specifies the launch template to use and optionally the instance types (overrides) that are used to provision EC2 instances to fulfill On-Demand and Spot capacities. Required when creating a mixed instances policy.

            • LaunchTemplateSpecification (dict) --

              The launch template to use.

              • LaunchTemplateId (string) --

                The ID of the launch template. To get the template ID, use the Amazon EC2 DescribeLaunchTemplates API operation. New launch templates can be created using the Amazon EC2 CreateLaunchTemplate API.

                Conditional: You must specify either a LaunchTemplateId or a LaunchTemplateName .

              • LaunchTemplateName (string) --

                The name of the launch template. To get the template name, use the Amazon EC2 DescribeLaunchTemplates API operation. New launch templates can be created using the Amazon EC2 CreateLaunchTemplate API.

                Conditional: You must specify either a LaunchTemplateId or a LaunchTemplateName .

              • Version (string) --

                The version number, $Latest , or $Default . To get the version number, use the Amazon EC2 DescribeLaunchTemplateVersions API operation. New launch template versions can be created using the Amazon EC2 CreateLaunchTemplateVersion API. If the value is $Latest , Amazon EC2 Auto Scaling selects the latest version of the launch template when launching instances. If the value is $Default , Amazon EC2 Auto Scaling selects the default version of the launch template when launching instances. The default value is $Default .

            • Overrides (list) --

              Any properties that you specify override the same properties in the launch template. If not provided, Amazon EC2 Auto Scaling uses the instance type specified in the launch template when it launches an instance.

              • (dict) --

                Describes an override for a launch template. The maximum number of instance types that can be associated with an Auto Scaling group is 40. The maximum number of distinct launch templates you can define for an Auto Scaling group is 20. For more information about configuring overrides, see Configuring overrides in the Amazon EC2 Auto Scaling User Guide .

                • InstanceType (string) --

                  The instance type, such as m3.xlarge . You must use an instance type that is supported in your requested Region and Availability Zones. For more information, see Instance types in the Amazon Elastic Compute Cloud User Guide .

                • WeightedCapacity (string) --

                  The number of capacity units provided by the specified instance type in terms of virtual CPUs, memory, storage, throughput, or other relative performance characteristic. When a Spot or On-Demand Instance is provisioned, the capacity units count toward the desired capacity. Amazon EC2 Auto Scaling provisions instances until the desired capacity is totally fulfilled, even if this results in an overage. For example, if there are 2 units remaining to fulfill capacity, and Amazon EC2 Auto Scaling can only provision an instance with a WeightedCapacity of 5 units, the instance is provisioned, and the desired capacity is exceeded by 3 units. For more information, see Instance weighting for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide . Value must be in the range of 1 to 999.

                • LaunchTemplateSpecification (dict) --

                  Provides the launch template to be used when launching the instance type. For example, some instance types might require a launch template with a different AMI. If not provided, Amazon EC2 Auto Scaling uses the launch template that's defined for your mixed instances policy. For more information, see Specifying a different launch template for an instance type in the Amazon EC2 Auto Scaling User Guide .

                  • LaunchTemplateId (string) --

                    The ID of the launch template. To get the template ID, use the Amazon EC2 DescribeLaunchTemplates API operation. New launch templates can be created using the Amazon EC2 CreateLaunchTemplate API.

                    Conditional: You must specify either a LaunchTemplateId or a LaunchTemplateName .

                  • LaunchTemplateName (string) --

                    The name of the launch template. To get the template name, use the Amazon EC2 DescribeLaunchTemplates API operation. New launch templates can be created using the Amazon EC2 CreateLaunchTemplate API.

                    Conditional: You must specify either a LaunchTemplateId or a LaunchTemplateName .

                  • Version (string) --

                    The version number, $Latest , or $Default . To get the version number, use the Amazon EC2 DescribeLaunchTemplateVersions API operation. New launch template versions can be created using the Amazon EC2 CreateLaunchTemplateVersion API. If the value is $Latest , Amazon EC2 Auto Scaling selects the latest version of the launch template when launching instances. If the value is $Default , Amazon EC2 Auto Scaling selects the default version of the launch template when launching instances. The default value is $Default .

          • InstancesDistribution (dict) --

            Specifies the instances distribution. If not provided, the value for each property in InstancesDistribution uses a default value.

            • OnDemandAllocationStrategy (string) --

              Indicates how to allocate instance types to fulfill On-Demand capacity. The only valid value is prioritized , which is also the default value. This strategy uses the order of instance types in the LaunchTemplateOverrides to define the launch priority of each instance type. The first instance type in the array is prioritized higher than the last. If all your On-Demand capacity cannot be fulfilled using your highest priority instance, then the Auto Scaling groups launches the remaining capacity using the second priority instance type, and so on.

            • OnDemandBaseCapacity (integer) --

              The minimum amount of the Auto Scaling group's capacity that must be fulfilled by On-Demand Instances. This base portion is provisioned first as your group scales. Defaults to 0 if not specified. If you specify weights for the instance types in the overrides, set the value of OnDemandBaseCapacity in terms of the number of capacity units, and not the number of instances.

            • OnDemandPercentageAboveBaseCapacity (integer) --

              Controls the percentages of On-Demand Instances and Spot Instances for your additional capacity beyond OnDemandBaseCapacity . Expressed as a number (for example, 20 specifies 20% On-Demand Instances, 80% Spot Instances). Defaults to 100 if not specified. If set to 100, only On-Demand Instances are provisioned.

            • SpotAllocationStrategy (string) --

              Indicates how to allocate instances across Spot Instance pools.

              If the allocation strategy is lowest-price , the Auto Scaling group launches instances using the Spot pools with the lowest price, and evenly allocates your instances across the number of Spot pools that you specify. Defaults to lowest-price if not specified.

              If the allocation strategy is capacity-optimized (recommended), the Auto Scaling group launches instances using Spot pools that are optimally chosen based on the available Spot capacity. Alternatively, you can use capacity-optimized-prioritized and set the order of instance types in the list of launch template overrides from highest to lowest priority (from first to last in the list). Amazon EC2 Auto Scaling honors the instance type priorities on a best-effort basis but optimizes for capacity first.

            • SpotInstancePools (integer) --

              The number of Spot Instance pools across which to allocate your Spot Instances. The Spot pools are determined from the different instance types in the overrides. Valid only when the Spot allocation strategy is lowest-price . Value must be in the range of 1 to 20. Defaults to 2 if not specified.

            • SpotMaxPrice (string) --

              The maximum price per unit hour that you are willing to pay for a Spot Instance. If you leave the value at its default (empty), Amazon EC2 Auto Scaling uses the On-Demand price as the maximum Spot price. To remove a value that you previously set, include the property but specify an empty string ("") for the value.

        • MinSize (integer) --

          The minimum size of the group.

        • MaxSize (integer) --

          The maximum size of the group.

        • DesiredCapacity (integer) --

          The desired size of the group.

        • PredictedCapacity (integer) --

          The predicted capacity of the group when it has a predictive scaling policy.

        • DefaultCooldown (integer) --

          The duration of the default cooldown period, in seconds.

        • AvailabilityZones (list) --

          One or more Availability Zones for the group.

          • (string) --

        • LoadBalancerNames (list) --

          One or more load balancers associated with the group.

          • (string) --

        • TargetGroupARNs (list) --

          The Amazon Resource Names (ARN) of the target groups for your load balancer.

          • (string) --

        • HealthCheckType (string) --

          The service to use for the health checks. The valid values are EC2 and ELB . If you configure an Auto Scaling group to use ELB health checks, it considers the instance unhealthy if it fails either the EC2 status checks or the load balancer health checks.

        • HealthCheckGracePeriod (integer) --

          The amount of time, in seconds, that Amazon EC2 Auto Scaling waits before checking the health status of an EC2 instance that has come into service.

        • Instances (list) --

          The EC2 instances associated with the group.

          • (dict) --

            Describes an EC2 instance.

            • InstanceId (string) --

              The ID of the instance.

            • InstanceType (string) --

              The instance type of the EC2 instance.

            • AvailabilityZone (string) --

              The Availability Zone in which the instance is running.

            • LifecycleState (string) --

              A description of the current lifecycle state. The Quarantined state is not used. For information about lifecycle states, see Instance lifecycle in the Amazon EC2 Auto Scaling User Guide .

            • HealthStatus (string) --

              The last reported health status of the instance. "Healthy" means that the instance is healthy and should remain in service. "Unhealthy" means that the instance is unhealthy and that Amazon EC2 Auto Scaling should terminate and replace it.

            • LaunchConfigurationName (string) --

              The launch configuration associated with the instance.

            • LaunchTemplate (dict) --

              The launch template for the instance.

              • LaunchTemplateId (string) --

                The ID of the launch template. To get the template ID, use the Amazon EC2 DescribeLaunchTemplates API operation. New launch templates can be created using the Amazon EC2 CreateLaunchTemplate API.

                Conditional: You must specify either a LaunchTemplateId or a LaunchTemplateName .

              • LaunchTemplateName (string) --

                The name of the launch template. To get the template name, use the Amazon EC2 DescribeLaunchTemplates API operation. New launch templates can be created using the Amazon EC2 CreateLaunchTemplate API.

                Conditional: You must specify either a LaunchTemplateId or a LaunchTemplateName .

              • Version (string) --

                The version number, $Latest , or $Default . To get the version number, use the Amazon EC2 DescribeLaunchTemplateVersions API operation. New launch template versions can be created using the Amazon EC2 CreateLaunchTemplateVersion API. If the value is $Latest , Amazon EC2 Auto Scaling selects the latest version of the launch template when launching instances. If the value is $Default , Amazon EC2 Auto Scaling selects the default version of the launch template when launching instances. The default value is $Default .

            • ProtectedFromScaleIn (boolean) --

              Indicates whether the instance is protected from termination by Amazon EC2 Auto Scaling when scaling in.

            • WeightedCapacity (string) --

              The number of capacity units contributed by the instance based on its instance type.

              Valid Range: Minimum value of 1. Maximum value of 999.

        • CreatedTime (datetime) --

          The date and time the group was created.

        • SuspendedProcesses (list) --

          The suspended processes associated with the group.

          • (dict) --

            Describes an auto scaling process that has been suspended.

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

            • ProcessName (string) --

              The name of the suspended process.

            • SuspensionReason (string) --

              The reason that the process was suspended.

        • PlacementGroup (string) --

          The name of the placement group into which to launch your instances, if any.

        • VPCZoneIdentifier (string) --

          One or more subnet IDs, if applicable, separated by commas.

        • EnabledMetrics (list) --

          The metrics enabled for the group.

          • (dict) --

            Describes an enabled metric.

            • Metric (string) --

              One of the following metrics:

              • GroupMinSize

              • GroupMaxSize

              • GroupDesiredCapacity

              • GroupInServiceInstances

              • GroupPendingInstances

              • GroupStandbyInstances

              • GroupTerminatingInstances

              • GroupTotalInstances

              • GroupInServiceCapacity

              • GroupPendingCapacity

              • GroupStandbyCapacity

              • GroupTerminatingCapacity

              • GroupTotalCapacity

              • WarmPoolDesiredCapacity

              • WarmPoolWarmedCapacity

              • WarmPoolPendingCapacity

              • WarmPoolTerminatingCapacity

              • WarmPoolTotalCapacity

              • GroupAndWarmPoolDesiredCapacity

              • GroupAndWarmPoolTotalCapacity

            • Granularity (string) --

              The granularity of the metric. The only valid value is 1Minute .

        • Status (string) --

          The current state of the group when the DeleteAutoScalingGroup operation is in progress.

        • Tags (list) --

          The tags for the group.

          • (dict) --

            Describes a tag for an Auto Scaling group.

            • ResourceId (string) --

              The name of the group.

            • ResourceType (string) --

              The type of resource. The only supported value is auto-scaling-group .

            • Key (string) --

              The tag key.

            • Value (string) --

              The tag value.

            • PropagateAtLaunch (boolean) --

              Determines whether the tag is added to new instances as they are launched in the group.

        • TerminationPolicies (list) --

          The termination policies for the group.

          • (string) --

        • NewInstancesProtectedFromScaleIn (boolean) --

          Indicates whether newly launched instances are protected from termination by Amazon EC2 Auto Scaling when scaling in.

        • ServiceLinkedRoleARN (string) --

          The Amazon Resource Name (ARN) of the service-linked role that the Auto Scaling group uses to call other AWS services on your behalf.

        • MaxInstanceLifetime (integer) --

          The maximum amount of time, in seconds, that an instance can be in service.

          Valid Range: Minimum value of 0.

        • CapacityRebalance (boolean) --

          Indicates whether Capacity Rebalancing is enabled.

        • WarmPoolConfiguration (dict) --

          The warm pool for the group.

          • MaxGroupPreparedCapacity (integer) --

            The maximum number of instances that are allowed to be in the warm pool or in any state except Terminated for the Auto Scaling group.

          • MinSize (integer) --

            The minimum number of instances to maintain in the warm pool.

          • PoolState (string) --

            The instance state to transition to after the lifecycle actions are complete.

          • Status (string) --

            The status of a warm pool that is marked for deletion.

        • WarmPoolSize (integer) --

          The current size of the warm pool.

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

DescribePolicies (updated) Link ¶
Changes (response)
{'ScalingPolicies': {'PredictiveScalingConfiguration': {'MaxCapacityBreachBehavior': 'HonorMaxCapacity '
                                                                                     '| '
                                                                                     'IncreaseMaxCapacity',
                                                        'MaxCapacityBuffer': 'integer',
                                                        'MetricSpecifications': [{'PredefinedLoadMetricSpecification': {'PredefinedMetricType': 'ASGTotalCPUUtilization '
                                                                                                                                                '| '
                                                                                                                                                'ASGTotalNetworkIn '
                                                                                                                                                '| '
                                                                                                                                                'ASGTotalNetworkOut '
                                                                                                                                                '| '
                                                                                                                                                'ALBTargetGroupRequestCount',
                                                                                                                        'ResourceLabel': 'string'},
                                                                                  'PredefinedMetricPairSpecification': {'PredefinedMetricType': 'ASGCPUUtilization '
                                                                                                                                                '| '
                                                                                                                                                'ASGNetworkIn '
                                                                                                                                                '| '
                                                                                                                                                'ASGNetworkOut '
                                                                                                                                                '| '
                                                                                                                                                'ALBRequestCount',
                                                                                                                        'ResourceLabel': 'string'},
                                                                                  'PredefinedScalingMetricSpecification': {'PredefinedMetricType': 'ASGAverageCPUUtilization '
                                                                                                                                                   '| '
                                                                                                                                                   'ASGAverageNetworkIn '
                                                                                                                                                   '| '
                                                                                                                                                   'ASGAverageNetworkOut '
                                                                                                                                                   '| '
                                                                                                                                                   'ALBRequestCountPerTarget',
                                                                                                                           'ResourceLabel': 'string'},
                                                                                  'TargetValue': 'double'}],
                                                        'Mode': 'ForecastAndScale '
                                                                '| '
                                                                'ForecastOnly',
                                                        'SchedulingBufferTime': 'integer'}}}

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 , TargetTrackingScaling , and PredictiveScaling .

  • (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,
            'PredictiveScalingConfiguration': {
                'MetricSpecifications': [
                    {
                        'TargetValue': 123.0,
                        'PredefinedMetricPairSpecification': {
                            'PredefinedMetricType': 'ASGCPUUtilization'|'ASGNetworkIn'|'ASGNetworkOut'|'ALBRequestCount',
                            'ResourceLabel': 'string'
                        },
                        'PredefinedScalingMetricSpecification': {
                            'PredefinedMetricType': 'ASGAverageCPUUtilization'|'ASGAverageNetworkIn'|'ASGAverageNetworkOut'|'ALBRequestCountPerTarget',
                            'ResourceLabel': 'string'
                        },
                        'PredefinedLoadMetricSpecification': {
                            'PredefinedMetricType': 'ASGTotalCPUUtilization'|'ASGTotalNetworkIn'|'ASGTotalNetworkOut'|'ALBTargetGroupRequestCount',
                            'ResourceLabel': 'string'
                        }
                    },
                ],
                'Mode': 'ForecastAndScale'|'ForecastOnly',
                'SchedulingBufferTime': 123,
                'MaxCapacityBreachBehavior': 'HonorMaxCapacity'|'IncreaseMaxCapacity',
                'MaxCapacityBuffer': 123
            }
        },
    ],
    '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) --

          One of the following policy types:

          • TargetTrackingScaling

          • StepScaling

          • SimpleScaling (default)

          • PredictiveScaling

          For more information, see Target tracking scaling policies and Step and simple scaling policies in the Amazon EC2 Auto Scaling User Guide .

        • AdjustmentType (string) --

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

        • MinAdjustmentStep (integer) --

          Available for backward compatibility. Use MinAdjustmentMagnitude instead.

        • MinAdjustmentMagnitude (integer) --

          The minimum value to scale by when the adjustment type is PercentChangeInCapacity .

        • 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 duration of the policy's cooldown period, in seconds.

        • StepAdjustments (list) --

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

          • (dict) --

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

              You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). 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

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

              This is an example: app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d.

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

          Indicates whether the policy is enabled ( true ) or disabled ( false ).

        • PredictiveScalingConfiguration (dict) --

          A predictive scaling policy.

          • MetricSpecifications (list) --

            This structure includes the metrics and target utilization to use for predictive scaling.

            This is an array, but we currently only support a single metric specification. That is, you can specify a target value and a single metric pair, or a target value and one scaling metric and one load metric.

            • (dict) --

              This structure specifies the metrics and target utilization settings for a predictive scaling policy.

              You must specify either a metric pair, or a load metric and a scaling metric individually. Specifying a metric pair instead of individual metrics provides a simpler way to configure metrics for a scaling policy. You choose the metric pair, and the policy automatically knows the correct sum and average statistics to use for the load metric and the scaling metric.

              Example

              • You create a predictive scaling policy and specify ALBRequestCount as the value for the metric pair and 1000.0 as the target value. For this type of metric, you must provide the metric dimension for the corresponding target group, so you also provide a resource label for the Application Load Balancer target group that is attached to your Auto Scaling group.

              • The number of requests the target group receives per minute provides the load metric, and the request count averaged between the members of the target group provides the scaling metric. In CloudWatch, this refers to the RequestCount and RequestCountPerTarget metrics, respectively.

              • For optimal use of predictive scaling, you adhere to the best practice of using a dynamic scaling policy to automatically scale between the minimum capacity and maximum capacity in response to real-time changes in resource utilization.

              • Amazon EC2 Auto Scaling consumes data points for the load metric over the last 14 days and creates an hourly load forecast for predictive scaling. (A minimum of 24 hours of data is required.)

              • After creating the load forecast, Amazon EC2 Auto Scaling determines when to reduce or increase the capacity of your Auto Scaling group in each hour of the forecast period so that the average number of requests received by each instance is as close to 1000 requests per minute as possible at all times.

              • TargetValue (float) --

                Specifies the target utilization.

              • PredefinedMetricPairSpecification (dict) --

                The metric pair specification from which Amazon EC2 Auto Scaling determines the appropriate scaling metric and load metric to use.

                • PredefinedMetricType (string) --

                  Indicates which metrics to use. There are two different types of metrics for each metric type: one is a load metric and one is a scaling metric. For example, if the metric type is ASGCPUUtilization , the Auto Scaling group's total CPU metric is used as the load metric, and the average CPU metric is used for the scaling metric.

                • ResourceLabel (string) --

                  A label that uniquely identifies a specific Application Load Balancer target group from which to determine the request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.

                  You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:

                  app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d .

                  Where:

                  • app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN

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

              • PredefinedScalingMetricSpecification (dict) --

                The scaling metric specification.

                • PredefinedMetricType (string) --

                  The metric type.

                • ResourceLabel (string) --

                  A label that uniquely identifies a specific Application Load Balancer target group from which to determine the request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.

                  You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:

                  app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d .

                  Where:

                  • app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN

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

              • PredefinedLoadMetricSpecification (dict) --

                The load metric specification.

                • PredefinedMetricType (string) --

                  The metric type.

                • ResourceLabel (string) --

                  A label that uniquely identifies a specific Application Load Balancer target group from which to determine the request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.

                  You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:

                  app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d .

                  Where:

                  • app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN

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

          • Mode (string) --

            The predictive scaling mode. Defaults to ForecastOnly if not specified.

          • SchedulingBufferTime (integer) --

            The amount of time, in seconds, by which the instance launch time can be advanced. For example, the forecast says to add capacity at 10:00 AM, and you choose to pre-launch instances by 5 minutes. In that case, the instances will be launched at 9:55 AM. The intention is to give resources time to be provisioned. It can take a few minutes to launch an EC2 instance. The actual amount of time required depends on several factors, such as the size of the instance and whether there are startup scripts to complete.

            The value must be less than the forecast interval duration of 3600 seconds (60 minutes). Defaults to 300 seconds if not specified.

          • MaxCapacityBreachBehavior (string) --

            Defines the behavior that should be applied if the forecast capacity approaches or exceeds the maximum capacity of the Auto Scaling group. Defaults to HonorMaxCapacity if not specified.

            The following are possible values:

            • HonorMaxCapacity - Amazon EC2 Auto Scaling cannot scale out capacity higher than the maximum capacity. The maximum capacity is enforced as a hard limit.

            • IncreaseMaxCapacity - Amazon EC2 Auto Scaling can scale out capacity higher than the maximum capacity when the forecast capacity is close to or exceeds the maximum capacity. The upper limit is determined by the forecasted capacity and the value for MaxCapacityBuffer .

          • MaxCapacityBuffer (integer) --

            The size of the capacity buffer to use when the forecast capacity is close to or exceeds the maximum capacity. The value is specified as a percentage relative to the forecast capacity. For example, if the buffer is 10, this means a 10 percent buffer, such that if the forecast capacity is 50, and the maximum capacity is 40, then the effective maximum capacity is 55.

            If set to 0, Amazon EC2 Auto Scaling may scale capacity higher than the maximum capacity to equal but not exceed forecast capacity.

            Required if the MaxCapacityBreachBehavior property is set to IncreaseMaxCapacity , and cannot be used otherwise.

    • 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)
{'PredictiveScalingConfiguration': {'MaxCapacityBreachBehavior': 'HonorMaxCapacity '
                                                                 '| '
                                                                 'IncreaseMaxCapacity',
                                    'MaxCapacityBuffer': 'integer',
                                    'MetricSpecifications': [{'PredefinedLoadMetricSpecification': {'PredefinedMetricType': 'ASGTotalCPUUtilization '
                                                                                                                            '| '
                                                                                                                            'ASGTotalNetworkIn '
                                                                                                                            '| '
                                                                                                                            'ASGTotalNetworkOut '
                                                                                                                            '| '
                                                                                                                            'ALBTargetGroupRequestCount',
                                                                                                    'ResourceLabel': 'string'},
                                                              'PredefinedMetricPairSpecification': {'PredefinedMetricType': 'ASGCPUUtilization '
                                                                                                                            '| '
                                                                                                                            'ASGNetworkIn '
                                                                                                                            '| '
                                                                                                                            'ASGNetworkOut '
                                                                                                                            '| '
                                                                                                                            'ALBRequestCount',
                                                                                                    'ResourceLabel': 'string'},
                                                              'PredefinedScalingMetricSpecification': {'PredefinedMetricType': 'ASGAverageCPUUtilization '
                                                                                                                               '| '
                                                                                                                               'ASGAverageNetworkIn '
                                                                                                                               '| '
                                                                                                                               'ASGAverageNetworkOut '
                                                                                                                               '| '
                                                                                                                               'ALBRequestCountPerTarget',
                                                                                                       'ResourceLabel': 'string'},
                                                              'TargetValue': 'double'}],
                                    'Mode': 'ForecastAndScale | ForecastOnly',
                                    'SchedulingBufferTime': 'integer'}}

Creates or updates a scaling policy for an Auto Scaling group. Scaling policies are used to scale an Auto Scaling group based on configurable metrics. If no policies are defined, the dynamic scaling and predictive scaling features are not used.

For more information about using dynamic scaling, see Target tracking scaling policies and Step and simple scaling policies in the Amazon EC2 Auto Scaling User Guide .

For more information about using predictive scaling, see Predictive scaling for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide .

You can view the scaling policies for an Auto Scaling group using the DescribePolicies API call. If you are no longer using a scaling policy, you can delete it by calling the DeletePolicy API.

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,
    PredictiveScalingConfiguration={
        'MetricSpecifications': [
            {
                'TargetValue': 123.0,
                'PredefinedMetricPairSpecification': {
                    'PredefinedMetricType': 'ASGCPUUtilization'|'ASGNetworkIn'|'ASGNetworkOut'|'ALBRequestCount',
                    'ResourceLabel': 'string'
                },
                'PredefinedScalingMetricSpecification': {
                    'PredefinedMetricType': 'ASGAverageCPUUtilization'|'ASGAverageNetworkIn'|'ASGAverageNetworkOut'|'ALBRequestCountPerTarget',
                    'ResourceLabel': 'string'
                },
                'PredefinedLoadMetricSpecification': {
                    'PredefinedMetricType': 'ASGTotalCPUUtilization'|'ASGTotalNetworkIn'|'ASGTotalNetworkOut'|'ALBTargetGroupRequestCount',
                    'ResourceLabel': 'string'
                }
            },
        ],
        'Mode': 'ForecastAndScale'|'ForecastOnly',
        'SchedulingBufferTime': 123,
        'MaxCapacityBreachBehavior': 'HonorMaxCapacity'|'IncreaseMaxCapacity',
        'MaxCapacityBuffer': 123
    }
)
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

One of the following policy types:

  • TargetTrackingScaling

  • StepScaling

  • SimpleScaling (default)

  • PredictiveScaling

type AdjustmentType

string

param 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 MinAdjustmentStep

integer

param MinAdjustmentStep

Available for backward compatibility. Use MinAdjustmentMagnitude instead.

type MinAdjustmentMagnitude

integer

param 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 ScalingAdjustment

integer

param 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 Cooldown

integer

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

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

  • (dict) --

    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 (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. 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 TargetTrackingConfiguration

dict

param TargetTrackingConfiguration

A target tracking scaling policy. Provides 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 (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.

      You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). 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

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

      This is an example: app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d.

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

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 PredictiveScalingConfiguration

dict

param PredictiveScalingConfiguration

A predictive scaling policy. Provides support for only predefined metrics.

Predictive scaling works with CPU utilization, network in/out, and the Application Load Balancer request count.

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

Required if the policy type is PredictiveScaling .

  • MetricSpecifications (list) -- [REQUIRED]

    This structure includes the metrics and target utilization to use for predictive scaling.

    This is an array, but we currently only support a single metric specification. That is, you can specify a target value and a single metric pair, or a target value and one scaling metric and one load metric.

    • (dict) --

      This structure specifies the metrics and target utilization settings for a predictive scaling policy.

      You must specify either a metric pair, or a load metric and a scaling metric individually. Specifying a metric pair instead of individual metrics provides a simpler way to configure metrics for a scaling policy. You choose the metric pair, and the policy automatically knows the correct sum and average statistics to use for the load metric and the scaling metric.

      Example

      • You create a predictive scaling policy and specify ALBRequestCount as the value for the metric pair and 1000.0 as the target value. For this type of metric, you must provide the metric dimension for the corresponding target group, so you also provide a resource label for the Application Load Balancer target group that is attached to your Auto Scaling group.

      • The number of requests the target group receives per minute provides the load metric, and the request count averaged between the members of the target group provides the scaling metric. In CloudWatch, this refers to the RequestCount and RequestCountPerTarget metrics, respectively.

      • For optimal use of predictive scaling, you adhere to the best practice of using a dynamic scaling policy to automatically scale between the minimum capacity and maximum capacity in response to real-time changes in resource utilization.

      • Amazon EC2 Auto Scaling consumes data points for the load metric over the last 14 days and creates an hourly load forecast for predictive scaling. (A minimum of 24 hours of data is required.)

      • After creating the load forecast, Amazon EC2 Auto Scaling determines when to reduce or increase the capacity of your Auto Scaling group in each hour of the forecast period so that the average number of requests received by each instance is as close to 1000 requests per minute as possible at all times.

      • TargetValue (float) -- [REQUIRED]

        Specifies the target utilization.

      • PredefinedMetricPairSpecification (dict) --

        The metric pair specification from which Amazon EC2 Auto Scaling determines the appropriate scaling metric and load metric to use.

        • PredefinedMetricType (string) -- [REQUIRED]

          Indicates which metrics to use. There are two different types of metrics for each metric type: one is a load metric and one is a scaling metric. For example, if the metric type is ASGCPUUtilization , the Auto Scaling group's total CPU metric is used as the load metric, and the average CPU metric is used for the scaling metric.

        • ResourceLabel (string) --

          A label that uniquely identifies a specific Application Load Balancer target group from which to determine the request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.

          You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:

          app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d .

          Where:

          • app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN

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

      • PredefinedScalingMetricSpecification (dict) --

        The scaling metric specification.

        • PredefinedMetricType (string) -- [REQUIRED]

          The metric type.

        • ResourceLabel (string) --

          A label that uniquely identifies a specific Application Load Balancer target group from which to determine the request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.

          You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:

          app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d .

          Where:

          • app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN

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

      • PredefinedLoadMetricSpecification (dict) --

        The load metric specification.

        • PredefinedMetricType (string) -- [REQUIRED]

          The metric type.

        • ResourceLabel (string) --

          A label that uniquely identifies a specific Application Load Balancer target group from which to determine the request count served by your Auto Scaling group. You can't specify a resource label unless the target group is attached to the Auto Scaling group.

          You create the resource label by appending the final portion of the load balancer ARN and the final portion of the target group ARN into a single value, separated by a forward slash (/). The format of the resource label is:

          app/EC2Co-EcsEl-1TKLTMITMM0EO/f37c06a68c1748aa/targetgroup/EC2Co-Defau-LDNM7Q3ZH1ZN/6d4ea56ca2d6a18d .

          Where:

          • app/<load-balancer-name>/<load-balancer-id> is the final portion of the load balancer ARN

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

  • Mode (string) --

    The predictive scaling mode. Defaults to ForecastOnly if not specified.

  • SchedulingBufferTime (integer) --

    The amount of time, in seconds, by which the instance launch time can be advanced. For example, the forecast says to add capacity at 10:00 AM, and you choose to pre-launch instances by 5 minutes. In that case, the instances will be launched at 9:55 AM. The intention is to give resources time to be provisioned. It can take a few minutes to launch an EC2 instance. The actual amount of time required depends on several factors, such as the size of the instance and whether there are startup scripts to complete.

    The value must be less than the forecast interval duration of 3600 seconds (60 minutes). Defaults to 300 seconds if not specified.

  • MaxCapacityBreachBehavior (string) --

    Defines the behavior that should be applied if the forecast capacity approaches or exceeds the maximum capacity of the Auto Scaling group. Defaults to HonorMaxCapacity if not specified.

    The following are possible values:

    • HonorMaxCapacity - Amazon EC2 Auto Scaling cannot scale out capacity higher than the maximum capacity. The maximum capacity is enforced as a hard limit.

    • IncreaseMaxCapacity - Amazon EC2 Auto Scaling can scale out capacity higher than the maximum capacity when the forecast capacity is close to or exceeds the maximum capacity. The upper limit is determined by the forecasted capacity and the value for MaxCapacityBuffer .

  • MaxCapacityBuffer (integer) --

    The size of the capacity buffer to use when the forecast capacity is close to or exceeds the maximum capacity. The value is specified as a percentage relative to the forecast capacity. For example, if the buffer is 10, this means a 10 percent buffer, such that if the forecast capacity is 50, and the maximum capacity is 40, then the effective maximum capacity is 55.

    If set to 0, Amazon EC2 Auto Scaling may scale capacity higher than the maximum capacity to equal but not exceed forecast capacity.

    Required if the MaxCapacityBreachBehavior property is set to IncreaseMaxCapacity , and cannot be used otherwise.

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.