Here is sample ansible tasks:
- lambda:
name: 'lambdaName'
state: present
register: lambdaResult
- cloudwatchevent_rule:
name: 'lambdaNameevent'
targets:
- arn: '{{ lambdaResult.configuration.function_arn }}'
id: "1"
Everytime I run the above ansible tasks it will create new version of lambda and gives me back "configuration.function_arn" which will be versioned. I use the "function_arn" to create new event.
So, the created event is pointed to
arn:aws:lambda:region:somenumber:function:lambdaName:10
And, when I delete lambda by doing
- lambda:
name: 'lambdaName'
state: absent
It doesn't remove the referenced event (lambdaNameevent).
How do I delete the referenced event on deletion of lambda ?