1

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 ?

1 Answer 1

2

Pretty sure you just have to clean up the cloudwatch event in another task after you remove the lambda

- lambda:
    name: 'lambdaName'
    state: absent

- cloudwatchevent_rule:
    name: 'lambdaNameevent'
    state: absent
Sign up to request clarification or add additional context in comments.

1 Comment

I was hoping, it will remove the reference. Anyway Thank you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.