scaling_policies
Creates, updates, deletes or gets a scaling_policy
resource or lists scaling_policies
in a region
Overview
Name | scaling_policies |
Type | Resource |
Description | The AWS::AutoScaling::ScalingPolicy resource specifies an Amazon EC2 Auto Scaling scaling policy so that the Auto Scaling group can scale the number of instances available for your application. |
Id | aws.autoscaling.scaling_policies |
Fields
Name | Datatype | Description |
---|---|---|
metric_aggregation_type | string | The aggregation type for the CloudWatch metrics. The valid values are Minimum, Maximum, and Average. If the aggregation type is null, the value is treated as Average. Valid only if the policy type is StepScaling. |
policy_name | string | |
policy_type | string | One of the following policy types: TargetTrackingScaling, StepScaling, SimpleScaling (default), PredictiveScaling |
predictive_scaling_configuration | object | A predictive scaling policy. Includes support for predefined metrics only. |
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. For exact capacity, you must specify a positive value. Required if the policy type is SimpleScaling. (Not used with any other policy type.) |
cooldown | string | 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. |
step_adjustments | 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.) |
auto_scaling_group_name | string | The name of the Auto Scaling group. |
min_adjustment_magnitude | 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. |
target_tracking_configuration | object | A target tracking scaling policy. Includes support for predefined or customized metrics. |
estimated_instance_warmup | integer | 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. |
adjustment_type | string | Specifies how the scaling adjustment is interpreted. The valid values are ChangeInCapacity, ExactCapacity, and PercentChangeInCapacity. |
arn | string | The ARN of the AutoScaling scaling policy |
region | string | AWS region. |
Methods
Name | Accessible by | Required Params |
---|---|---|
create_resource | INSERT | AutoScalingGroupName, region |
delete_resource | DELETE | data__Identifier, region |
update_resource | UPDATE | data__Identifier, data__PatchDocument, region |
list_resources | SELECT | region |
get_resource | SELECT | data__Identifier, region |
SELECT
examples
Gets all scaling_policies
in a region.
SELECT
region,
metric_aggregation_type,
policy_name,
policy_type,
predictive_scaling_configuration,
scaling_adjustment,
cooldown,
step_adjustments,
auto_scaling_group_name,
min_adjustment_magnitude,
target_tracking_configuration,
estimated_instance_warmup,
adjustment_type,
arn
FROM aws.autoscaling.scaling_policies
WHERE region = 'us-east-1';
Gets all properties from an individual scaling_policy
.
SELECT
region,
metric_aggregation_type,
policy_name,
policy_type,
predictive_scaling_configuration,
scaling_adjustment,
cooldown,
step_adjustments,
auto_scaling_group_name,
min_adjustment_magnitude,
target_tracking_configuration,
estimated_instance_warmup,
adjustment_type,
arn
FROM aws.autoscaling.scaling_policies
WHERE region = 'us-east-1' AND data__Identifier = '<Arn>';
INSERT
example
Use the following StackQL query and manifest file to create a new scaling_policy
resource, using stack-deploy
.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO aws.autoscaling.scaling_policies (
AutoScalingGroupName,
region
)
SELECT
'{{ AutoScalingGroupName }}',
'{{ region }}';
/*+ create */
INSERT INTO aws.autoscaling.scaling_policies (
MetricAggregationType,
PolicyType,
PredictiveScalingConfiguration,
ScalingAdjustment,
Cooldown,
StepAdjustments,
AutoScalingGroupName,
MinAdjustmentMagnitude,
TargetTrackingConfiguration,
EstimatedInstanceWarmup,
AdjustmentType,
region
)
SELECT
'{{ MetricAggregationType }}',
'{{ PolicyType }}',
'{{ PredictiveScalingConfiguration }}',
'{{ ScalingAdjustment }}',
'{{ Cooldown }}',
'{{ StepAdjustments }}',
'{{ AutoScalingGroupName }}',
'{{ MinAdjustmentMagnitude }}',
'{{ TargetTrackingConfiguration }}',
'{{ EstimatedInstanceWarmup }}',
'{{ AdjustmentType }}',
'{{ region }}';
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: scaling_policy
props:
- name: MetricAggregationType
value: '{{ MetricAggregationType }}'
- name: PolicyType
value: '{{ PolicyType }}'
- name: PredictiveScalingConfiguration
value:
MetricSpecifications:
- CustomizedCapacityMetricSpecification:
MetricDataQueries:
- Label: '{{ Label }}'
MetricStat:
Metric:
MetricName: '{{ MetricName }}'
Dimensions:
- Value: '{{ Value }}'
Name: '{{ Name }}'
Namespace: '{{ Namespace }}'
Stat: '{{ Stat }}'
Unit: '{{ Unit }}'
Id: '{{ Id }}'
ReturnData: '{{ ReturnData }}'
Expression: '{{ Expression }}'
CustomizedLoadMetricSpecification:
MetricDataQueries:
- null
CustomizedScalingMetricSpecification:
MetricDataQueries:
- null
PredefinedLoadMetricSpecification:
ResourceLabel: '{{ ResourceLabel }}'
PredefinedMetricType: '{{ PredefinedMetricType }}'
TargetValue: null
PredefinedScalingMetricSpecification:
ResourceLabel: '{{ ResourceLabel }}'
PredefinedMetricType: '{{ PredefinedMetricType }}'
PredefinedMetricPairSpecification:
ResourceLabel: '{{ ResourceLabel }}'
PredefinedMetricType: '{{ PredefinedMetricType }}'
MaxCapacityBreachBehavior: '{{ MaxCapacityBreachBehavior }}'
MaxCapacityBuffer: '{{ MaxCapacityBuffer }}'
SchedulingBufferTime: '{{ SchedulingBufferTime }}'
Mode: '{{ Mode }}'
- name: ScalingAdjustment
value: '{{ ScalingAdjustment }}'
- name: Cooldown
value: '{{ Cooldown }}'
- name: StepAdjustments
value:
- MetricIntervalUpperBound: null
MetricIntervalLowerBound: null
ScalingAdjustment: '{{ ScalingAdjustment }}'
- name: AutoScalingGroupName
value: '{{ AutoScalingGroupName }}'
- name: MinAdjustmentMagnitude
value: '{{ MinAdjustmentMagnitude }}'
- name: TargetTrackingConfiguration
value:
CustomizedMetricSpecification:
MetricName: '{{ MetricName }}'
Dimensions:
- null
Statistic: '{{ Statistic }}'
Unit: '{{ Unit }}'
Namespace: '{{ Namespace }}'
TargetValue: null
DisableScaleIn: '{{ DisableScaleIn }}'
PredefinedMetricSpecification:
ResourceLabel: '{{ ResourceLabel }}'
PredefinedMetricType: '{{ PredefinedMetricType }}'
- name: EstimatedInstanceWarmup
value: '{{ EstimatedInstanceWarmup }}'
- name: AdjustmentType
value: '{{ AdjustmentType }}'
DELETE
example
/*+ delete */
DELETE FROM aws.autoscaling.scaling_policies
WHERE data__Identifier = '<Arn>'
AND region = 'us-east-1';
Permissions
To operate on the scaling_policies
resource, the following permissions are required:
Create
autoscaling:DescribePolicies,
autoscaling:PutScalingPolicy,
cloudwatch:GetMetricData
Read
autoscaling:DescribePolicies
Update
autoscaling:DescribePolicies,
autoscaling:PutScalingPolicy,
cloudwatch:GetMetricData
Delete
autoscaling:DeletePolicy,
autoscaling:DescribePolicies
List
autoscaling:DescribePolicies