# Trigger lambda when CloudFormation stack deploy completed successfully

**URL:** <https://forum.serverless.com/t/trigger-lambda-when-cloudformation-stack-deploy-completed-successfully/3988>\
**Category:** Serverless Framework\
**Created:** [March 12, 2018, 1:34pm UTC](https://forum.serverless.com/t/trigger-lambda-when-cloudformation-stack-deploy-completed-successfully/3988 "2018-03-12T13:34:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tgfischer](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/tgfischer/32/2171_2.png) [@tgfischer](https://forum.serverless.com/u/tgfischer)\
**Post date:** [March 12, 2018, 1:34pm UTC](https://forum.serverless.com/t/trigger-lambda-when-cloudformation-stack-deploy-completed-successfully/3988/1 "2018-03-12T13:34:49Z")

</div>

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](https://serverless.com/framework/docs/providers/aws/events/cloudwatch-event/), 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 🙂

---

<div class="post-metadata">

**Author:** ![JuHwon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/juhwon/32/2014_2.png) [@JuHwon](https://forum.serverless.com/u/JuHwon)\
**Post date:** [June 7, 2018, 7:25pm UTC](https://forum.serverless.com/t/trigger-lambda-when-cloudformation-stack-deploy-completed-successfully/3988/2 "2018-06-07T19:25:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tgfischer](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/tgfischer/32/2171_2.png) [@tgfischer](https://forum.serverless.com/u/tgfischer)\
**Post date:** [June 14, 2018, 7:49pm UTC](https://forum.serverless.com/t/trigger-lambda-when-cloudformation-stack-deploy-completed-successfully/3988/3 "2018-06-14T19:49:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JuHwon](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/juhwon/32/2014_2.png) [@JuHwon](https://forum.serverless.com/u/JuHwon)\
**Post date:** [June 14, 2018, 8:04pm UTC](https://forum.serverless.com/t/trigger-lambda-when-cloudformation-stack-deploy-completed-successfully/3988/4 "2018-06-14T20:04:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![saurav1007](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/saurav1007/32/4938_2.png) [@saurav1007](https://forum.serverless.com/u/saurav1007)\
**Post date:** [December 26, 2020, 5:29pm UTC](https://forum.serverless.com/t/trigger-lambda-when-cloudformation-stack-deploy-completed-successfully/3988/5 "2020-12-26T17:29:58Z")

</div>

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