policies
Creates, updates, deletes, gets or lists a policies resource.
Overview
| Name | policies |
| Type | Resource |
| Id | aws.autoscaling.policies |
Fields
The following fields are returned by SELECT queries:
- describe_policies
| Name | Datatype | Description |
|---|---|---|
adjustment_type | string | Specifies how the scaling adjustment is interpreted (for example, an absolute number or a percentage). The valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity. |
alarms | string | The CloudWatch alarms related to the policy. |
auto_scaling_group_name | string | The name of the Auto Scaling group. |
cooldown | integer | The duration of the policy's cooldown period, in seconds. |
enabled | boolean | Indicates whether the policy is enabled (true) or disabled (false). |
estimated_instance_warmup | integer | The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics. |
metric_aggregation_type | string | The aggregation type for the CloudWatch metrics. The valid values are Minimum, Maximum, and Average. |
min_adjustment_magnitude | integer | The minimum value to scale by when the adjustment type is PercentChangeInCapacity. |
min_adjustment_step | integer | Available for backward compatibility. Use MinAdjustmentMagnitude instead. |
policy_arn | string | The Amazon Resource Name (ARN) of the policy. |
policy_name | string | The name of the scaling policy. |
policy_type | 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. |
predictive_scaling_configuration | string | A predictive scaling policy. |
scaling_adjustment | integer | The amount by which to scale, based on the specified adjustment type. A positive value adds to the current capacity while a negative number removes from the current capacity. |
step_adjustments | string | A set of adjustments that enable you to scale based on the size of the alarm breach. |
target_tracking_configuration | string | A target tracking scaling policy. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
describe_policies | select | region | AutoScalingGroupName, PolicyNames, PolicyTypes, NextToken, MaxRecords | Gets information about the scaling policies in the account and Region. |
put_scaling_policy | replace | AutoScalingGroupName, PolicyName, region | PolicyType, AdjustmentType, MinAdjustmentStep, MinAdjustmentMagnitude, ScalingAdjustment, Cooldown, MetricAggregationType, StepAdjustments, EstimatedInstanceWarmup, TargetTrackingConfiguration, Enabled, PredictiveScalingConfiguration | 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. |
delete_policy | delete | PolicyName, region | AutoScalingGroupName | 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. |
execute_policy | exec | PolicyName, region | AutoScalingGroupName, HonorCooldown, MetricValue, BreachThreshold | Executes 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.
| Name | Datatype | Description |
|---|---|---|
AutoScalingGroupName | string | The name of the Auto Scaling group. |
PolicyName | string | The name or ARN of the policy. |
region | string | AWS region (default: us-east-1) |
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. Required if the policy type is StepScaling or SimpleScaling. For more information, see Scaling adjustment types in the Amazon EC2 Auto Scaling User Guide. |
AutoScalingGroupName | string | The name of the Auto Scaling group. |
BreachThreshold | number (double) | The breach threshold for the alarm. Required if the policy type is StepScaling and not supported otherwise. |
Cooldown | integer | A 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 |
Enabled | boolean | Indicates 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. |
EstimatedInstanceWarmup | integer | Not 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. |
HonorCooldown | boolean | Indicates 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. |
MaxRecords | integer | The maximum number of items to be returned with each call. The default value is 50 and the maximum value is 100. |
MetricAggregationType | string | The aggregation type for the CloudWatch metrics. The valid values are Minimum, Maximum, and Average. If the aggregation type is null, the value is treated as Average. Valid only if the policy type is StepScaling. |
MetricValue | number (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. |
MinAdjustmentMagnitude | integer | The minimum value to scale by when the adjustment type is PercentChangeInCapacity. For example, suppose that you create a step scaling policy to scale out an Auto Scaling group by 25 percent and you specify a MinAdjustmentMagnitude of 2. If the group has 4 instances and the scaling policy is performed, 25 percent of 4 is 1. However, because you specified a MinAdjustmentMagnitude of 2, Amazon EC2 Auto Scaling scales out the group by 2 instances. Valid only if the policy type is StepScaling or SimpleScaling. For more information, see Scaling adjustment types in the Amazon EC2 Auto Scaling User Guide. 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. |
MinAdjustmentStep | integer | Available for backward compatibility. Use MinAdjustmentMagnitude instead. |
NextToken | string | The token for the next set of items to return. (You received this token from a previous call.) |
PolicyNames | array | The 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. |
PolicyType | string | One of the following policy types: TargetTrackingScaling StepScaling SimpleScaling (default) PredictiveScaling |
PolicyTypes | array | One or more policy types. The valid values are SimpleScaling, StepScaling, TargetTrackingScaling, and PredictiveScaling. |
PredictiveScalingConfiguration | object | A 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. |
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. For exact capacity, you must specify a non-negative value. Required if the policy type is SimpleScaling. (Not used with any other policy type.) |
StepAdjustments | array | 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.) |
TargetTrackingConfiguration | object | A 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
- describe_policies
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
- put_scaling_policy
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
- delete_policy
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
- execute_policy
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 }}'
;