Trigger lambda when CloudFormation stack deploy completed successfully

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

    handler: src/handler.hello
    handler: src/
      - cloudwatchEvent:
              - "aws.cloudformation"

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:

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

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

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.

1 Like

Hey JuHwon,
Can you please share the custom resource code?