Reputation: 465
I am creating S3 buckets using AWS SAM and I want them to be populated with files after SAM deploy. Is there a way to populate the S3 buckets by default from SAM with files? An idea I has was if there is a way to trigger a lambda when the SAM application is deployed that can populate the bucket.
Upvotes: 1
Views: 634
Reputation: 8147
Look into using a Cloudformation Custom resource.
This allows you to invoke your own code (i.e. Lambda) during a cloudformation stack creation, update and deletion event. I have seen people use this to populate an S3 bucket as well as ensure all files are deleted from the bucket when you tear down (since CF will fail to delete a bucket if it has files in it).
Upvotes: 1