2
votes

I am trying to s 1) Enable the versioning on S3 buckets and 2) Delete previous versions after say 30 days. Do you know which lifecycle rule should I be setting to achieve 2?

One of the rule is Permanently delete previous versions of objects. Under that rule, you need to set Number of days after objects become previous version. The language in the public doc is not clear. Does that number mean after those number of days, the current S3 object becomes previous and gets deleted? In that case I will loose the S3 objects right?

Can someone help if my above understanding is correct?

Which rule should I set so that current version will be intact and only previous versions to be deleted after 30 days?

I looked at these examples, but all of them attempts to simply delete any S3 object that is older than 30 days. But I am trying to delete only the previous versions of the object.

Examples 1: Deleting old object versions on AWS S3 2: AWS: Delete Permanently S3 objects less than 30 days using 'Lifecycle Rule'

Thanks,

Pavan

1

1 Answers

4
votes

You would use "Permanently delete previous versions of objects".

You would then enter "Number of days after objects become previous versions", which tells it to delete the object after than many days from when the version was not the Current version.

A Version will only ever become a Previous (non-current) version if a new version of the object is uploaded with the same name.

Does that number mean after those number of days, the current S3 object becomes previous and gets deleted

The current version will remain the current version until a user (eg You!) uploads a file with the same name. That will become the current version, and the "Current" version that was previously there becomes a "Previous" version.