2
votes

Is there a way to add a trigger to a Lambda function in Cloudformation for s3 events, where the s3 bucket already exists? (i.e, is not created by said template)

I have tried to find an example of this online, but it appears that the only way to set this trigger in CF is by using the bucket notification configuration.

1

1 Answers

2
votes

Cloudformation cannot do this directly. However, Cloudformation Custom Resources can call Lambda functions, and Lambda functions can do whatever you program them to do. You could write a Lambda function which creates or deletes some resource based on whatever logic you want.

See more: AWS Lambda-backed Custom Resources - AWS CloudFormation