diff --git a/changelogs/fragments/2355-float-stepscaling-bounds.yml b/changelogs/fragments/2355-float-stepscaling-bounds.yml new file mode 100644 index 00000000000..a36c46659ee --- /dev/null +++ b/changelogs/fragments/2355-float-stepscaling-bounds.yml @@ -0,0 +1,2 @@ +bugfixes: + - autoscaling_policy - allow float type for ``step_adjustments`` ``lower_bound`` and ``upper_bound`` parameters (https://github.com/ansible-collections/community.aws/issues/2355) diff --git a/plugins/modules/autoscaling_policy.py b/plugins/modules/autoscaling_policy.py index 6e26edf0cf3..d2634f67966 100644 --- a/plugins/modules/autoscaling_policy.py +++ b/plugins/modules/autoscaling_policy.py @@ -94,12 +94,12 @@ elements: dict suboptions: lower_bound: - type: int + type: float description: - The lower bound for the difference between the alarm threshold and the CloudWatch metric. upper_bound: - type: int + type: float description: - The upper bound for the difference between the alarm threshold and the CloudWatch metric. @@ -549,7 +549,9 @@ def delete_scaling_policy(connection, module): def main(): step_adjustment_spec = dict( - lower_bound=dict(type="int"), upper_bound=dict(type="int"), scaling_adjustment=dict(type="int", required=True) + lower_bound=dict(type="float"), + upper_bound=dict(type="float"), + scaling_adjustment=dict(type="int", required=True), ) predefined_metric_spec = dict( diff --git a/tests/integration/targets/autoscaling_policy/tasks/main.yml b/tests/integration/targets/autoscaling_policy/tasks/main.yml index 684522d641a..bf606ce53d7 100644 --- a/tests/integration/targets/autoscaling_policy/tasks/main.yml +++ b/tests/integration/targets/autoscaling_policy/tasks/main.yml @@ -153,6 +153,52 @@ - result.changed - result.adjustment_type == "PercentChangeInCapacity" + - name: Update Step Scaling policy with float bounds + autoscaling_policy: + name: "{{ resource_prefix }}_stepscaling_policy" + asg_name: "{{ scaling_policy_asg_name }}" + state: present + policy_type: StepScaling + metric_aggregation: Maximum + step_adjustments: + - upper_bound: 10.5 + scaling_adjustment: 50 + - lower_bound: 10.5 + upper_bound: 30.75 + scaling_adjustment: 75 + - lower_bound: 30.75 + scaling_adjustment: 100 + adjustment_type: "PercentChangeInCapacity" + register: result + + - assert: + that: + - result.policy_name == resource_prefix ~ '_stepscaling_policy' + - result.changed + + - name: Update Step Scaling policy with float bounds (idempotency) + autoscaling_policy: + name: "{{ resource_prefix }}_stepscaling_policy" + asg_name: "{{ scaling_policy_asg_name }}" + state: present + policy_type: StepScaling + metric_aggregation: Maximum + step_adjustments: + - upper_bound: 10.5 + scaling_adjustment: 50 + - lower_bound: 10.5 + upper_bound: 30.75 + scaling_adjustment: 75 + - lower_bound: 30.75 + scaling_adjustment: 100 + adjustment_type: "PercentChangeInCapacity" + register: result + + - assert: + that: + - result.policy_name == resource_prefix ~ '_stepscaling_policy' + - not result.changed + - name: Remove Step Scaling policy autoscaling_policy: name: "{{ resource_prefix }}_stepscaling_policy"