mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Added redrive policy options (#2245)
This commit is contained in:
parent
6c9c4e7482
commit
5de3dbbf6d
1 changed files with 18 additions and 3 deletions
|
@ -25,6 +25,7 @@ version_added: "2.0"
|
|||
author:
|
||||
- Alan Loi (@loia)
|
||||
- Fernando Jose Pando (@nand0p)
|
||||
- Nadir Lloret (@nadirollo)
|
||||
requirements:
|
||||
- "boto >= 2.33.0"
|
||||
options:
|
||||
|
@ -69,13 +70,19 @@ options:
|
|||
required: false
|
||||
default: null
|
||||
version_added: "2.1"
|
||||
redrive_policy:
|
||||
description:
|
||||
- json dict with the redrive_policy (see example)
|
||||
required: false
|
||||
default: null
|
||||
version_added: "2.2"
|
||||
extends_documentation_fragment:
|
||||
- aws
|
||||
- ec2
|
||||
"""
|
||||
|
||||
EXAMPLES = '''
|
||||
# Create SQS queue
|
||||
# Create SQS queue with redrive policy
|
||||
- sqs_queue:
|
||||
name: my-queue
|
||||
region: ap-southeast-2
|
||||
|
@ -85,6 +92,9 @@ EXAMPLES = '''
|
|||
delivery_delay: 30
|
||||
receive_message_wait_time: 20
|
||||
policy: "{{ json_dict }}"
|
||||
redrive_policy:
|
||||
maxReceiveCount: 5
|
||||
deadLetterTargetArn: arn:aws:sqs:eu-west-1:123456789012:my-dead-queue
|
||||
|
||||
# Delete SQS queue
|
||||
- sqs_queue:
|
||||
|
@ -112,6 +122,7 @@ def create_or_update_sqs_queue(connection, module):
|
|||
delivery_delay=module.params.get('delivery_delay'),
|
||||
receive_message_wait_time=module.params.get('receive_message_wait_time'),
|
||||
policy=module.params.get('policy'),
|
||||
redrive_policy=module.params.get('redrive_policy')
|
||||
)
|
||||
|
||||
result = dict(
|
||||
|
@ -147,7 +158,8 @@ def update_sqs_queue(queue,
|
|||
maximum_message_size=None,
|
||||
delivery_delay=None,
|
||||
receive_message_wait_time=None,
|
||||
policy=None):
|
||||
policy=None,
|
||||
redrive_policy=None):
|
||||
changed = False
|
||||
|
||||
changed = set_queue_attribute(queue, 'VisibilityTimeout', default_visibility_timeout,
|
||||
|
@ -162,6 +174,8 @@ def update_sqs_queue(queue,
|
|||
check_mode=check_mode) or changed
|
||||
changed = set_queue_attribute(queue, 'Policy', policy,
|
||||
check_mode=check_mode) or changed
|
||||
changed = set_queue_attribute(queue, 'RedrivePolicy', redrive_policy,
|
||||
check_mode=check_mode) or changed
|
||||
return changed
|
||||
|
||||
|
||||
|
@ -175,7 +189,7 @@ def set_queue_attribute(queue, attribute, value, check_mode=False):
|
|||
existing_value = ''
|
||||
|
||||
# convert dict attributes to JSON strings (sort keys for comparing)
|
||||
if attribute is 'Policy':
|
||||
if attribute in ['Policy', 'RedrivePolicy']:
|
||||
value = json.dumps(value, sort_keys=True)
|
||||
if existing_value:
|
||||
existing_value = json.dumps(json.loads(existing_value), sort_keys=True)
|
||||
|
@ -224,6 +238,7 @@ def main():
|
|||
delivery_delay=dict(type='int'),
|
||||
receive_message_wait_time=dict(type='int'),
|
||||
policy=dict(type='dict', required=False),
|
||||
redrive_policy=dict(type='dict', required=False),
|
||||
))
|
||||
|
||||
module = AnsibleModule(
|
||||
|
|
Loading…
Reference in a new issue