Skip to main content

policies

Creates, updates, deletes, gets or lists a policies resource.

Overview

Namepolicies
TypeResource
Idaws.autoscaling.policies

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
adjustment_typestringSpecifies how the scaling adjustment is interpreted (for example, an absolute number or a percentage). The valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity.
alarmsstringThe CloudWatch alarms related to the policy.
auto_scaling_group_namestringThe name of the Auto Scaling group.
cooldownintegerThe duration of the policy's cooldown period, in seconds.
enabledbooleanIndicates whether the policy is enabled (true) or disabled (false).
estimated_instance_warmupintegerThe estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics.
metric_aggregation_typestringThe aggregation type for the CloudWatch metrics. The valid values are Minimum, Maximum, and Average.
min_adjustment_magnitudeintegerThe minimum value to scale by when the adjustment type is PercentChangeInCapacity.
min_adjustment_stepintegerAvailable for backward compatibility. Use MinAdjustmentMagnitude instead.
policy_arnstringThe Amazon Resource Name (ARN) of the policy.
policy_namestringThe name of the scaling policy.
policy_typestringOne 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.
predictive_scaling_configurationstringA predictive scaling policy.
scaling_adjustmentintegerThe 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.
step_adjustmentsstringA set of adjustments that enable you to scale based on the size of the alarm breach.
target_tracking_configurationstringA target tracking scaling policy.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_policiesselectregionAutoScalingGroupName, PolicyNames, PolicyTypes, NextToken, MaxRecordsGets information about the scaling policies in the account and Region.
put_scaling_policyreplaceAutoScalingGroupName, PolicyName, regionPolicyType, AdjustmentType, MinAdjustmentStep, MinAdjustmentMagnitude, ScalingAdjustment, Cooldown, MetricAggregationType, StepAdjustments, EstimatedInstanceWarmup, TargetTrackingConfiguration, Enabled, PredictiveScalingConfigurationCreates 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.
delete_policydeletePolicyName, regionAutoScalingGroupNameDeletes the specified scaling policy. Deleting either a step scaling policy or a simple scaling policy deletes the underlying alarm action, but does not delete the alarm, even if it no longer has an associated action. For more information, see Delete a scaling policy in the Amazon EC2 Auto Scaling User Guide.
execute_policyexecPolicyName, regionAutoScalingGroupName, HonorCooldown, MetricValue, BreachThresholdExecutes the specified policy. This can be useful for testing the design of your scaling policy.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
AutoScalingGroupNamestringThe name of the Auto Scaling group.
PolicyNamestringThe name or ARN of the policy.
regionstringAWS region (default: us-east-1)
AdjustmentTypestringSpecifies 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.
AutoScalingGroupNamestringThe name of the Auto Scaling group.
BreachThresholdnumber (double)The breach threshold for the alarm. Required if the policy type is StepScaling and not supported otherwise.
CooldownintegerA cooldown period, in seconds, that applies to a specific simple scaling policy. When a cooldown period is specified here, it overrides the default cooldown. 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. Default: None
EnabledbooleanIndicates whether the scaling policy is enabled or disabled. The default is enabled. For more information, see Disable a scaling policy for an Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.
EstimatedInstanceWarmupintegerNot needed if the default instance warmup is defined for the group. The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics. This warm-up period applies to instances launched due to a specific target tracking or step scaling policy. When a warm-up period is specified here, it overrides the default instance warmup. Valid only if the policy type is TargetTrackingScaling or StepScaling. The default is to use the value for the default instance warmup defined for the group. If default instance warmup is null, then EstimatedInstanceWarmup falls back to the value of default cooldown.
HonorCooldownbooleanIndicates whether Amazon EC2 Auto Scaling waits for the cooldown period to complete before executing the policy. 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.
MaxRecordsintegerThe maximum number of items to be returned with each call. The default value is 50 and the maximum value is 100.
MetricAggregationTypestringThe 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.
MetricValuenumber (double)The metric value to compare to BreachThreshold. This enables you to execute a policy of type StepScaling and determine which step adjustment to use. For example, if the breach threshold is 50 and you want to use a step adjustment with a lower bound of 0 and an upper bound of 10, you can set the metric value to 59. If you specify a metric value that doesn't correspond to a step adjustment for the policy, the call returns an error. Required if the policy type is StepScaling and not supported otherwise.
MinAdjustmentMagnitudeintegerThe 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. 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.
MinAdjustmentStepintegerAvailable for backward compatibility. Use MinAdjustmentMagnitude instead.
NextTokenstringThe token for the next set of items to return. (You received this token from a previous call.)
PolicyNamesarrayThe names of one or more policies. If you omit this property, all policies are described. If a group name is provided, the results are limited to that group. If you specify an unknown policy name, it is ignored with no error. Array Members: Maximum number of 50 items.
PolicyTypestringOne of the following policy types: TargetTrackingScaling StepScaling SimpleScaling (default) PredictiveScaling
PolicyTypesarrayOne or more policy types. The valid values are SimpleScaling, StepScaling, TargetTrackingScaling, and PredictiveScaling.
PredictiveScalingConfigurationobjectA predictive scaling policy. Provides support for predefined and custom metrics. Predefined metrics include 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.
ScalingAdjustmentintegerThe 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 non-negative value. Required if the policy type is SimpleScaling. (Not used with any other policy type.)
StepAdjustmentsarrayA 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.)
TargetTrackingConfigurationobjectA target tracking scaling policy. Provides support for predefined or custom metrics. The following predefined metrics are available: ASGAverageCPUUtilization ASGAverageNetworkIn ASGAverageNetworkOut ALBRequestCountPerTarget If you specify ALBRequestCountPerTarget for the metric, you must specify the ResourceLabel property with the PredefinedMetricSpecification. For more information, see TargetTrackingConfiguration in the Amazon EC2 Auto Scaling API Reference. Required if the policy type is TargetTrackingScaling.

SELECT examples

Gets information about the scaling policies in the account and Region.

SELECT
adjustment_type,
alarms,
auto_scaling_group_name,
cooldown,
enabled,
estimated_instance_warmup,
metric_aggregation_type,
min_adjustment_magnitude,
min_adjustment_step,
policy_arn,
policy_name,
policy_type,
predictive_scaling_configuration,
scaling_adjustment,
step_adjustments,
target_tracking_configuration
FROM aws.autoscaling.policies
WHERE region = '{{ region }}' -- required
AND AutoScalingGroupName = '{{ AutoScalingGroupName }}'
AND PolicyNames = '{{ PolicyNames }}'
AND PolicyTypes = '{{ PolicyTypes }}'
AND NextToken = '{{ NextToken }}'
AND MaxRecords = '{{ MaxRecords }}'
;

REPLACE examples

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.

REPLACE aws.autoscaling.policies
SET
-- No updatable properties
WHERE
AutoScalingGroupName = '{{ AutoScalingGroupName }}' --required
AND PolicyName = '{{ PolicyName }}' --required
AND region = '{{ region }}' --required
AND PolicyType = '{{ PolicyType}}'
AND AdjustmentType = '{{ AdjustmentType}}'
AND MinAdjustmentStep = '{{ MinAdjustmentStep}}'
AND MinAdjustmentMagnitude = '{{ MinAdjustmentMagnitude}}'
AND ScalingAdjustment = '{{ ScalingAdjustment}}'
AND Cooldown = '{{ Cooldown}}'
AND MetricAggregationType = '{{ MetricAggregationType}}'
AND StepAdjustments = '{{ StepAdjustments}}'
AND EstimatedInstanceWarmup = '{{ EstimatedInstanceWarmup}}'
AND TargetTrackingConfiguration = '{{ TargetTrackingConfiguration}}'
AND Enabled = {{ Enabled}}
AND PredictiveScalingConfiguration = '{{ PredictiveScalingConfiguration}}'
RETURNING
alarms,
policy_arn;

DELETE examples

Deletes the specified scaling policy. Deleting either a step scaling policy or a simple scaling policy deletes the underlying alarm action, but does not delete the alarm, even if it no longer has an associated action. For more information, see Delete a scaling policy in the Amazon EC2 Auto Scaling User Guide.

DELETE FROM aws.autoscaling.policies
WHERE PolicyName = '{{ PolicyName }}' --required
AND region = '{{ region }}' --required
AND AutoScalingGroupName = '{{ AutoScalingGroupName }}'
;

Lifecycle Methods

Executes the specified policy. This can be useful for testing the design of your scaling policy.

EXEC aws.autoscaling.policies.execute_policy
@PolicyName='{{ PolicyName }}' --required,
@region='{{ region }}' --required,
@AutoScalingGroupName='{{ AutoScalingGroupName }}',
@HonorCooldown={{ HonorCooldown }},
@MetricValue='{{ MetricValue }}',
@BreachThreshold='{{ BreachThreshold }}'
;