community / community.aws / 3.4.0 / module / ec2_scaling_policy Create or delete AWS scaling policies for Autoscaling groups | "added in version" 1.0.0 of community.aws" Authors: Zacharie Eakin (@zeekin), Will Thames (@willthames)community.aws.ec2_scaling_policy (3.4.0) — module
Install with ansible-galaxy collection install community.aws:==3.4.0
collections: - name: community.aws version: 3.4.0
Can create or delete scaling policies for autoscaling groups.
Referenced autoscaling groups must already exist.
- name: Simple Scale Down policy community.aws.ec2_scaling_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 - community.aws.ec2_scaling_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: description: - Unique name for the scaling policy. required: true type: str state: choices: - present - absent default: present description: - Register or deregister the policy. type: str region: aliases: - aws_region - ec2_region description: - The AWS region to use. If not specified then the value of the AWS_REGION or EC2_REGION environment variable, if any, is used. See U(http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region) type: str ec2_url: aliases: - aws_endpoint_url - endpoint_url description: - URL to use to connect to EC2 or your Eucalyptus cloud (by default the module will use EC2 endpoints). Ignored for modules where region is required. Must be specified for all other modules if region is not used. If not set then the value of the EC2_URL environment variable, if any, is used. type: str profile: aliases: - aws_profile description: - Using I(profile) will override I(aws_access_key), I(aws_secret_key) and I(security_token) and support for passing them at the same time as I(profile) has been deprecated. - I(aws_access_key), I(aws_secret_key) and I(security_token) will be made mutually exclusive with I(profile) after 2022-06-01. type: str asg_name: description: - Name of the associated autoscaling group. - Required if I(state) is C(present). type: str cooldown: description: - The minimum period of time (in seconds) between which autoscaling actions can take place. - Only used when I(policy_type) is C(SimpleScaling). type: int aws_config: description: - A dictionary to modify the botocore configuration. - Parameters can be found at U(https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config). - Only the 'user_agent' key is used for boto modules. See U(http://boto.cloudhackers.com/en/latest/boto_config_tut.html#boto) for more boto configuration. type: dict policy_type: choices: - StepScaling - SimpleScaling default: SimpleScaling description: - Auto scaling adjustment policy. type: str aws_ca_bundle: description: - The location of a CA Bundle to use when validating SSL certificates. - Not used by boto 2 based modules. - 'Note: The CA Bundle is read ''module'' side and may need to be explicitly copied from the controller if not run locally.' type: path aws_access_key: aliases: - ec2_access_key - access_key description: - C(AWS access key). If not set then the value of the C(AWS_ACCESS_KEY_ID), C(AWS_ACCESS_KEY) or C(EC2_ACCESS_KEY) environment variable is used. - If I(profile) is set this parameter is ignored. - Passing the I(aws_access_key) and I(profile) options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01. type: str aws_secret_key: aliases: - ec2_secret_key - secret_key description: - C(AWS secret key). If not set then the value of the C(AWS_SECRET_ACCESS_KEY), C(AWS_SECRET_KEY), or C(EC2_SECRET_KEY) environment variable is used. - If I(profile) is set this parameter is ignored. - Passing the I(aws_secret_key) and I(profile) options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01. type: str security_token: aliases: - aws_security_token - access_token description: - C(AWS STS security token). If not set then the value of the C(AWS_SECURITY_TOKEN) or C(EC2_SECURITY_TOKEN) environment variable is used. - If I(profile) is set this parameter is ignored. - Passing the I(security_token) and I(profile) options at the same time has been deprecated and the options will be made mutually exclusive after 2022-06-01. type: str validate_certs: default: true description: - When set to "no", SSL certificates will not be validated for communication with the AWS APIs. type: bool adjustment_type: choices: - ChangeInCapacity - ExactCapacity - PercentChangeInCapacity description: - The type of change in capacity of the autoscaling group. - Required if I(state) is C(present). type: str step_adjustments: description: - list of dicts containing I(lower_bound), I(upper_bound) and I(scaling_adjustment) - Intervals must not overlap or have a gap between them. - At most, one item can have an undefined I(lower_bound). If any item has a negative lower_bound, then there must be a step adjustment with an undefined I(lower_bound). - At most, one item can have an undefined I(upper_bound). If any item has a positive upper_bound, then there must be a step adjustment with an undefined I(upper_bound). - The bounds are the amount over the alarm threshold at which the adjustment will trigger. This means that for an alarm threshold of 50, triggering at 75 requires a lower bound of 25. See U(http://docs.aws.amazon.com/AutoScaling/latest/APIReference/API_StepAdjustment.html). elements: dict suboptions: lower_bound: description: - The lower bound for the difference between the alarm threshold and the CloudWatch metric. type: int scaling_adjustment: description: - The amount by which to scale. required: true type: int upper_bound: description: - The upper bound for the difference between the alarm threshold and the CloudWatch metric. type: int type: list metric_aggregation: choices: - Minimum - Maximum - Average default: Average description: - The aggregation type for the CloudWatch metrics. - Only used when I(policy_type) is not C(SimpleScaling). type: str scaling_adjustment: description: - The amount by which the autoscaling group is adjusted by the policy. - A negative number has the effect of scaling down the ASG. - Units are numbers of instances for C(ExactCapacity) or C(ChangeInCapacity) or percent of existing instances for C(PercentChangeInCapacity). - Required when I(policy_type) is C(SimpleScaling). type: int min_adjustment_step: description: - Minimum amount of adjustment when policy is triggered. - Only used when I(adjustment_type) is C(PercentChangeInCapacity). type: int estimated_instance_warmup: description: - The estimated time, in seconds, until a newly launched instance can contribute to the CloudWatch metrics. type: int debug_botocore_endpoint_logs: default: 'no' description: - Use a botocore.endpoint logger to parse the unique (rather than total) "resource:action" API calls made during a task, outputing the set to the resource_actions key in the task results. Use the aws_resource_action callback to output to total list made during a playbook. The ANSIBLE_DEBUG_BOTOCORE_LOGS environment variable may also be used. type: bool
adjustment_type: description: Scaling policy adjustment type returned: always sample: PercentChangeInCapacity type: str alarms: contains: alarm_arn: description: ARN of the Cloudwatch alarm returned: always sample: arn:aws:cloudwatch:us-east-2:1234567890:alarm:cpu-very-high type: str alarm_name: description: name of the Cloudwatch alarm returned: always sample: cpu-very-high type: str description: Cloudwatch alarms related to the policy returned: always type: complex arn: description: ARN of the scaling policy. Provided for backward compatibility, value is the same as I(policy_arn) returned: always sample: arn:aws:autoscaling:us-east-2:123456789012:scalingPolicy:59e37526-bd27-42cf-adca-5cd3d90bc3b9:autoScalingGroupName/app-asg:policyName/app-policy type: str as_name: description: Auto Scaling Group name. Provided for backward compatibility, value is the same as I(auto_scaling_group_name) returned: always sample: app-asg type: str auto_scaling_group_name: description: Name of Auto Scaling Group returned: always sample: app-asg type: str metric_aggregation_type: description: Method used to aggregate metrics returned: when I(policy_type) is C(StepScaling) sample: Maximum type: str name: description: Name of the scaling policy. Provided for backward compatibility, value is the same as I(policy_name) returned: always sample: app-policy type: str policy_arn: description: ARN of scaling policy. returned: always sample: arn:aws:autoscaling:us-east-2:123456789012:scalingPolicy:59e37526-bd27-42cf-adca-5cd3d90bc3b9:autoScalingGroupName/app-asg:policyName/app-policy type: str policy_name: description: Name of scaling policy returned: always sample: app-policy type: str policy_type: description: Type of auto scaling policy returned: always sample: StepScaling type: str scaling_adjustment: description: Adjustment to make when alarm is triggered returned: When I(policy_type) is C(SimpleScaling) sample: 1 type: int step_adjustments: contains: metric_interval_lower_bound: description: Lower bound for metric interval returned: if step has a lower bound sample: 20.0 type: float metric_interval_upper_bound: description: Upper bound for metric interval returned: if step has an upper bound sample: 40.0 type: float scaling_adjustment: description: Adjustment to make if this step is reached returned: always sample: 50 type: int description: List of step adjustments returned: always type: complex