globaldatanetmenu

.Custom Resource with CloudFormation

Jun 1st 2019-1 min read

Use Case

If you include execution of a Lambda in your CloudFormation template and you update your Lambda Code, CloudFormation will not execute your Custom Resource again unless it detects that the template or parameters have been changed. Here are two Workarounds to invoke Custom Resources after CFN Update.

Workaround 1: Include a Parameter

A very easy way to execute the Custom Resource every time when your Lambda changed is to add a parameter to your Custom Resource (eg. a timestamp, which will always be different) - if this parameter changes, the custom resources will automatically be executed again.

Parameters: 
  LambdaExecutionTimestamp:
    Type: String
    Default: 201906010800
    
 Resources:
   ExecuteLambda:
    Type: 'Custom::ExecuteLambda'
    Properties:
      ServiceToken: !GetAtt
        - Lambda
        - Arn
      Timestamp: !Ref LambdaExecutionTimestamp

Workaround 2: Use SNS to invoke the Custom Ressource

Use an SNS trigger to invoke your Custom Resource, when your CloudFormation Stack is updated.

Blog Content

Additional Information: Handling AWS Cloudformation Events

globaldatanetCloud Development, Optimization & Automation

.Navigation

.Social

  • follow globaldatanet on instagram
  • follow globaldatanet on facebook
  • follow globaldatanet on twitter
  • follow globaldatanet on linkendin
  • follow globaldatanet on twitch
  •  listen to our serverless world podcast
  • follow globaldatanet's tech rss feed
  • follow globaldatanet at github
© 2024 by globaldatanet. All Right Reserved
Your privacy is important to us!

We use cookies on our website. Some of them are essential,while others help us to improve our online offer.
You can find more information in our Privacy policy