Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/2355-float-stepscaling-bounds.yml
Original file line number Diff line number Diff line change
@@ -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)
8 changes: 5 additions & 3 deletions plugins/modules/autoscaling_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down
46 changes: 46 additions & 0 deletions tests/integration/targets/autoscaling_policy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading