Skip to content

Commit

Permalink
Merge pull request #592 from msven/sqsQueueIdempotent
Browse files Browse the repository at this point in the history
Fix queue attribute comparison

SUMMARY

Fixes sqs queue attribute comparison so updates are not performed on subsequent runs.  Also adds integration tests to verify this behavior.

Fixes #578
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

sqs_queue
ADDITIONAL INFORMATION

Reviewed-by: Markus Bergholz <git@osuv.de>
Reviewed-by: Mark Chappell <None>
  • Loading branch information
ansible-zuul[bot] authored Jul 9, 2021
2 parents aaa1327 + bc1372a commit 3513a09
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
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 @@ -375,7 +375,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

0 comments on commit 3513a09

Please sign in to comment.