Saurabh
Saurabh

Reputation: 39

Remove old data from S3 based on last modified timestamp

I am working on a project dealing with images. It stores all the images in Amazon S3 and do some editing and then store that edited images again in S3 and then use the S3 urls.

Now, there are lot of images (>100000) and I need to query on what images were modified an year back so that I can save on my s3 cost by removing those images.

Upvotes: 0

Views: 869

Answers (2)

Maurice
Maurice

Reputation: 13197

Lifecycle Rules are the S3 Feature that helps you transition objects automatically to either cheaper storage classes or delete them after a certain period of time.

You can create these on the bucket for specific prefixes and then choose an action for the objects that match the prefix. These actions will be applied to the objects x amount of time after they have been created/modified based on your configuration.

Be aware that this happens asynchronously and not immediately, but usually within 48 hours if I recall correctly. Lifecycle rules have the benefit of being free.

Here's some more information:

Upvotes: 3

Shafqat Jamil Khan
Shafqat Jamil Khan

Reputation: 1037

You can specify lifecycle transitions and delete or move less frequently used objects/images to low cost storage. Please read https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-transition-general-considerations.html

Upvotes: 1

Related Questions