PARALLAX

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

NameTypeRequiredDefaultDescription
access_keystr
adjustment_typestr
asg_namestr
aws_ca_bundlepath
aws_configdict
cooldownint
debug_botocore_endpoint_logsboolfalse
endpoint_urlstr
estimated_instance_warmupint
metric_aggregationstrAverage
min_adjustment_stepint
namestryes
policy_typestrSimpleScaling
profilestr
regionstr
scaling_adjustmentint
secret_keystr
session_tokenstr
statestrpresent
step_adjustmentslist
target_tracking_configdict
validate_certsbooltrue

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
Search
    ↑ ↓ move↵ openesc close