Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way for object-level expiration in aws s3 buckets?

For example : One object tends to expire after 10 days , other one after 30 days of creation date. How can i ensure this object level expiration ?

I went through some guides that mentions rule for whole bucket but not for object specific expiration.

like image 325
Roohafza Avatar asked Sep 18 '25 00:09

Roohafza


1 Answers

There is no in-built capability to perform daily deletions on a per-object basis, but one way to achieve it would be:

  • When the objects are created, add a metadata tag with the desired deletion date
  • Configure Amazon CloudWatch Events to trigger an AWS Lambda function once per day
  • The AWS Lambda function can look for objects in the bucket that have reached/passed the deletion date stored in metadata
  • The function can then delete the objects

This would give you the ability to specify daily expirations.

like image 135
John Rotenstein Avatar answered Sep 23 '25 07:09

John Rotenstein