Have a requirement like need to delete buckets that are 15 days old and having a tag like Type: Test
.
Is this achievable using an AWS Lambda function?
Have a requirement like need to delete buckets that are 15 days old and having a tag like Type: Test
.
Is this achievable using an AWS Lambda function?
2
Answers
Yes, you could use AWS lambda to trigger object deletion. Your lambda would need to be triggered on a regular schedule by an Amazon CloudWatch Events rule. Below you can find info about tagging S3 Objects and performing actions using the S3 API that in your case would be called by the lambda function.
Unless you have a specific reason to use a lambda function, the task you need to be accomplished is the perfect use case for an S3 lifecycle rule. This would be the cleanest way to achieve your goal as you could just setup a rule that removes content according to age and tag.
In case you’re set on Lambda, Additional resources to write it can be found below:
AWS Lambda simply runs the code that you provide. So, you could write code that:
However, it would be easier (and cheaper) to use an S3 Lifecycle rule instead of an AWS Lambda function.