1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[cloud] Support deadletter queue configuration in lambda module (#21720)

* Add dead_letter_arn option for Lambda.py

* fix logic so DeadLetterConfig can be deleted
This commit is contained in:
Sloane Hertel 2017-02-23 16:04:45 -05:00 committed by Ryan Brown
parent 776116e809
commit 942ed42eb0

View file

@ -103,6 +103,12 @@ options:
default: None
aliases: [ 'environment' ]
version_added: "2.3"
dead_letter_arn:
description:
- The parent object that contains the target Amazon Resource Name (ARN) of an Amazon SQS queue or Amazon SNS topic.
required: false
default: None
version_added: "2.3"
author:
- 'Steyn Huizinga (@steynovich)'
extends_documentation_fragment:
@ -236,6 +242,7 @@ def main():
vpc_subnet_ids=dict(type='list', default=None),
vpc_security_group_ids=dict(type='list', default=None),
environment_variables=dict(type='dict', default=None),
dead_letter_arn=dict(type='str', default=None),
)
)
@ -266,6 +273,7 @@ def main():
vpc_subnet_ids = module.params.get('vpc_subnet_ids')
vpc_security_group_ids = module.params.get('vpc_security_group_ids')
environment_variables = module.params.get('environment_variables')
dead_letter_arn = module.params.get('dead_letter_arn')
check_mode = module.check_mode
changed = False
@ -324,6 +332,13 @@ def main():
func_kwargs.update({'MemorySize': memory_size})
if (environment_variables is not None) and (current_config['Environment']['Variables'] != environment_variables):
func_kwargs.update({'Environment':{'Variables': environment_variables}})
if dead_letter_arn is not None:
if current_config.get('DeadLetterConfig'):
if current_config['DeadLetterConfig']['TargetArn'] != dead_letter_arn:
func_kwargs.update({'DeadLetterConfig': {'TargetArn': dead_letter_arn}})
else:
if dead_letter_arn != "":
func_kwargs.update({'DeadLetterConfig': {'TargetArn': dead_letter_arn}})
# Check for unsupported mutation
if current_config['Runtime'] != runtime:
@ -442,6 +457,9 @@ def main():
'Environment':{'Variables': environment_variables}
}
if dead_letter_arn:
func_kwargs.update({'DeadLetterConfig': {'TargetARN': dead_letter_arn}})
# If VPC configuration is given
if vpc_subnet_ids or vpc_security_group_ids:
if len(vpc_subnet_ids) < 1: