I tried creating a set of lambdas using cloudformation. I want the lambdas to get triggered once they are created. I saw at various blogs to create a trigger to s3
or sns
but none seems to be a option to trigger lambda
once it has been created. Any options?
Yes, it is possible. Here are a few options:
Manually create an SNS Topic. Add an AWS::SNS::Subscription
to your stack with the lambda function as the Endpoint
and the SNS topic as the TopicArn
. On stack creation/update, configure Stack Event Notifications to be sent to this SNS topic.
--notification-arns
if creating/updating your stack using the AWS CLI or other AWS SDK.)Add a Custom Resource referencing a Lambda function to be called on creation.
DependsOn
attribute on the Custom Resource referencing the Resource you want to make sure is created first before the function is called.CREATE_IN_PROGRESS
, because the Custom Resource is part of the stack itself.DELETE_FAILED
state.Add the Lambda function reference to a Stack Output, then write a simple script that performs the stack creation and then manually invokes the Lambda function afterwards.