Trigger lambda when CloudFormation stack deploy completed successfully


#1

Hi. I’d like to create an event that triggers a lambda when the CloudFormation stack is successfully deployed to AWS. Can this be done with Serverless? I’ve tried looking at the events documentation here, and tried something similar to

functions:
  hello:
    handler: src/handler.hello
  world:
    handler: src/handler.world
    events:
      - cloudwatchEvent:
          event:
            source:
              - "aws.cloudformation"
            detail:
              state:
                "complete"

In the above code, I was hoping the function world would be invoked when the stack has completed updating. I could probably write a script that manually calls serverless invoke --function world after the deploy succeeds, but that just seems weird.

Any help would be appreciated :slight_smile:


#2

with which solution did you end up?
searching for a solution to this right now.


#3

We ended up writing a script that would execute the function after the deploy was completed. Not ideal, but it got the job done


#4

If anyone is searching for a solution and gets redirected here like me.
I ended up writing a custom cloud formation resource. I did not even know that these exist.
It depends of the use case of course, though for me, it was a good fit.