autoscaling_policy
Create or delete AWS scaling policies for Autoscaling groups
Collection: community.aws
Full Name: community.aws.autoscaling_policy
Synopsis
Create or delete AWS scaling policies for Autoscaling groups
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| access_key | str | |||
| adjustment_type | str | |||
| asg_name | str | |||
| aws_ca_bundle | path | |||
| aws_config | dict | |||
| cooldown | int | |||
| debug_botocore_endpoint_logs | bool | false | ||
| endpoint_url | str | |||
| estimated_instance_warmup | int | |||
| metric_aggregation | str | Average | ||
| min_adjustment_step | int | |||
| name | str | yes | ||
| policy_type | str | SimpleScaling | ||
| profile | str | |||
| region | str | |||
| scaling_adjustment | int | |||
| secret_key | str | |||
| session_token | str | |||
| state | str | present | ||
| step_adjustments | list | |||
| target_tracking_config | dict | |||
| validate_certs | bool | true |
Example
yaml
- name: Simple Scale Down policy
community.aws.autoscaling_policy:
state: present
region: US-XXX
name: "scaledown-policy"
adjustment_type: "ChangeInCapacity"
asg_name: "application-asg"
scaling_adjustment: -1
min_adjustment_step: 1
cooldown: 300
# For an alarm with a breach threshold of 20, the
# following creates a stepped policy:
# From 20-40 (0-20 above threshold), increase by 50% of existing capacity
# From 41-infinity, increase by 100% of existing capacity
- name: Create or delete AWS scaling policies for Autoscaling groups
community.aws.autoscaling_policy:
state: present
region: US-XXX
name: "step-scale-up-policy"
policy_type: StepScaling
metric_aggregation: Maximum
step_adjustments:
- upper_bound: 20
scaling_adjustment: 50
- lower_bound: 20
scaling_adjustment: 100
adjustment_type: "PercentChangeInCapacity"
asg_name: "application-asg"
- name: create TargetTracking predefined policy
community.aws.autoscaling_policy:
name: "predefined-policy-1"
policy_type: TargetTrackingScaling
target_tracking_config:
predefined_metric_spec:
predefined_metric_type: ASGAverageCPUUtilization
target_value: 98.0
asg_name: "asg-test-1"
register: result
- name: create TargetTracking predefined policy with resource_label
community.aws.autoscaling_policy:
name: "predefined-policy-1"
policy_type: TargetTrackingScaling
target_tracking_config:
predefined_metric_spec:
predefined_metric_type: ALBRequestCountPerTarget
resource_label: app/my-alb/778d41231d141a0f/targetgroup/my-alb-target-group/942f017f100becff
target_value: 98.0
asg_name: "asg-test-1"
register: result
- name: create TargetTrackingScaling custom policy
community.aws.autoscaling_policy:
name: "custom-policy-1"
policy_type: TargetTrackingScaling
target_tracking_config:
customized_metric_spec:
metric_name: metric_1
namespace: namespace_1
statistic: Minimum
unit: Gigabits
dimensions: [{'Name': 'dimension1', 'Value': 'value1'}]
disable_scalein: true
target_value: 98.0
asg_name: asg-test-1
register: result