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 | awscc.autoscaling.scaling_policies |
Fields
- get (all properties)
- list (identifiers only)
| 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. |
| Name | Datatype | Description |
|---|---|---|
arn | string | The ARN of the AutoScaling scaling policy |
region | string | AWS region. |
For more information, see AWS::AutoScaling::ScalingPolicy.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | scaling_policies | INSERT | AutoScalingGroupName, region |
delete_resource | scaling_policies | DELETE | Identifier, region |
update_resource | scaling_policies | UPDATE | Identifier, PatchDocument, region |
list_resources | scaling_policies_list_only | SELECT | region |
get_resource | scaling_policies | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
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 awscc.autoscaling.scaling_policies
WHERE
region = 'us-east-1' AND
Identifier = '{{ arn }}';
Lists all scaling_policies in a region.
SELECT
region,
arn
FROM awscc.autoscaling.scaling_policies_list_only
WHERE
region = 'us-east-1';
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 awscc.autoscaling.scaling_policies (
AutoScalingGroupName,
region
)
SELECT
'{{ auto_scaling_group_name }}',
'{{ region }}';
/*+ create */
INSERT INTO awscc.autoscaling.scaling_policies (
MetricAggregationType,
PolicyType,
PredictiveScalingConfiguration,
ScalingAdjustment,
Cooldown,
StepAdjustments,
AutoScalingGroupName,
MinAdjustmentMagnitude,
TargetTrackingConfiguration,
EstimatedInstanceWarmup,
AdjustmentType,
region
)
SELECT
'{{ metric_aggregation_type }}',
'{{ 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 }}',
'{{ region }}';
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: scaling_policy
props:
- name: metric_aggregation_type
value: '{{ metric_aggregation_type }}'
- name: policy_type
value: '{{ policy_type }}'
- name: predictive_scaling_configuration
value:
metric_specifications:
- customized_capacity_metric_specification:
metric_data_queries:
- label: '{{ label }}'
metric_stat:
metric:
metric_name: '{{ metric_name }}'
dimensions:
- value: '{{ value }}'
name: '{{ name }}'
namespace: '{{ namespace }}'
stat: '{{ stat }}'
unit: '{{ unit }}'
id: '{{ id }}'
return_data: '{{ return_data }}'
expression: '{{ expression }}'
customized_load_metric_specification:
metric_data_queries:
- null
customized_scaling_metric_specification:
metric_data_queries:
- null
predefined_load_metric_specification:
resource_label: '{{ resource_label }}'
predefined_metric_type: '{{ predefined_metric_type }}'
target_value: null
predefined_scaling_metric_specification:
resource_label: '{{ resource_label }}'
predefined_metric_type: '{{ predefined_metric_type }}'
predefined_metric_pair_specification:
resource_label: '{{ resource_label }}'
predefined_metric_type: '{{ predefined_metric_type }}'
max_capacity_breach_behavior: '{{ max_capacity_breach_behavior }}'
max_capacity_buffer: '{{ max_capacity_buffer }}'
scheduling_buffer_time: '{{ scheduling_buffer_time }}'
mode: '{{ mode }}'
- name: scaling_adjustment
value: '{{ scaling_adjustment }}'
- name: cooldown
value: '{{ cooldown }}'
- name: step_adjustments
value:
- metric_interval_upper_bound: null
metric_interval_lower_bound: null
scaling_adjustment: '{{ scaling_adjustment }}'
- name: auto_scaling_group_name
value: '{{ auto_scaling_group_name }}'
- name: min_adjustment_magnitude
value: '{{ min_adjustment_magnitude }}'
- name: target_tracking_configuration
value:
customized_metric_specification:
metric_name: '{{ metric_name }}'
dimensions:
- null
metrics:
- label: '{{ label }}'
metric_stat:
metric: null
stat: '{{ stat }}'
unit: '{{ unit }}'
period: '{{ period }}'
id: '{{ id }}'
return_data: '{{ return_data }}'
expression: '{{ expression }}'
period: '{{ period }}'
statistic: '{{ statistic }}'
unit: '{{ unit }}'
namespace: '{{ namespace }}'
period: '{{ period }}'
target_value: null
disable_scale_in: '{{ disable_scale_in }}'
predefined_metric_specification:
resource_label: '{{ resource_label }}'
predefined_metric_type: '{{ predefined_metric_type }}'
- name: estimated_instance_warmup
value: '{{ estimated_instance_warmup }}'
- name: adjustment_type
value: '{{ adjustment_type }}'
UPDATE example
Use the following StackQL query and manifest file to update a scaling_policy resource, using stack-deploy.
/*+ update */
UPDATE awscc.autoscaling.scaling_policies
SET PatchDocument = string('{{ {
"MetricAggregationType": metric_aggregation_type,
"PolicyType": policy_type,
"PredictiveScalingConfiguration": predictive_scaling_configuration,
"ScalingAdjustment": scaling_adjustment,
"Cooldown": cooldown,
"StepAdjustments": step_adjustments,
"MinAdjustmentMagnitude": min_adjustment_magnitude,
"TargetTrackingConfiguration": target_tracking_configuration,
"EstimatedInstanceWarmup": estimated_instance_warmup,
"AdjustmentType": adjustment_type
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ arn }}';
DELETE example
/*+ delete */
DELETE FROM awscc.autoscaling.scaling_policies
WHERE
Identifier = '{{ arn }}' AND
region = 'us-east-1';
Permissions
To operate on the scaling_policies resource, the following permissions are required:
- Create
- Read
- Update
- Delete
- List
autoscaling:DescribePolicies,
autoscaling:PutScalingPolicy,
cloudwatch:GetMetricData
autoscaling:DescribePolicies
autoscaling:DescribePolicies,
autoscaling:PutScalingPolicy,
cloudwatch:GetMetricData
autoscaling:DeletePolicy,
autoscaling:DescribePolicies
autoscaling:DescribePolicies