I am creating cloudFormation stack for s3 bucket (with the help of yaml template file). Is there a way by which we can automatically delete the created buckets? Can we configure the yaml templates such that the s3 bucket gets deleted after some time of its creation? If not what is the best way to programmaticaly delete the s3 buckets?
Tried to add
DeletionPolicy: Delete
But it is for retention of deleted files.
CodePudding user response:
The best way to achieve this is to create a cloudwatch event at a specific time that would trigger a lambda. This lambda could delete the file in the bucket and then delete the bucket.
You can build all that using cloudformation template.
CodePudding user response:
As far as I know
DeletePolicy
is used to determine what will happen when a bucket gets deleted.
You should look into lifecycle policy
instead if you want some sort of time based automation behind it.
Here are some examples: AWS DOCS