Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix queue attribute comparison #592

Merged
merged 2 commits into from
Jul 9, 2021
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/592-sqs_queue-idempotent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- sqs_queue - fix queue attribute comparison to make module idempotent (https://github.com/ansible-collections/community.aws/pull/592).
2 changes: 1 addition & 1 deletion plugins/modules/sqs_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def update_sqs_queue(module, client, queue_url):
new_value = str(new_value).lower()
value = str(value).lower()

if new_value == value:
if str(new_value) == str(value):
continue

# Boto3 expects strings
Expand Down
44 changes: 44 additions & 0 deletions tests/integration/targets/sqs_queue/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,50 @@
- create_result.policy.Version == "2012-10-17"
- create_result.policy.Statement[0].Effect == "Allow"
- create_result.policy.Statement[0].Action == "*"
- name: Test idempotentcy
sqs_queue:
name: "{{ create_result.name }}"
default_visibility_timeout: 900
delivery_delay: 900
maximum_message_size: 9009
message_retention_period: 900
receive_message_wait_time: 10
policy:
Version: "2012-10-17"
Statement:
Effect: Allow
Action: "*"
register: create_result
- name: Assert nothing changed
assert:
that:
- not create_result.changed
- name: Test update
sqs_queue:
name: "{{ create_result.name }}"
default_visibility_timeout: 899
delivery_delay: 899
maximum_message_size: 9008
message_retention_period: 899
receive_message_wait_time: 9
policy:
Version: "2012-10-17"
Statement:
Effect: Allow
Action: "*"
register: create_result
- name: Assert queue updated with configuration
assert:
that:
- create_result.changed
- create_result.default_visibility_timeout == 899
- create_result.delivery_delay == 899
- create_result.maximum_message_size == 9008
- create_result.message_retention_period == 899
- create_result.receive_message_wait_time == 9
- create_result.policy.Version == "2012-10-17"
- create_result.policy.Statement[0].Effect == "Allow"
- create_result.policy.Statement[0].Action == "*"
always:
- name: Cleaning up queue
sqs_queue:
Expand Down