How does the S3 lifecycle behavior against Expire current versions of objects and Permanently delete noncurrent versions of objects

0

We have a lambda function to tag S3 objects and hope to setup S3 lifecycle rule to delete tagged object. The S3 does NOT have versioning turned on.

So, we created a s3 lifecycle rule says: Limited the rule scope to one or more filters. Set object tags by providing key and value of the tag (did not specify minimum or maximum of object size) checked on both "Expire current versions of objects" and "permanently delete concurrent versions of objects.

Hence, we are forced to provide values for "Days after object creation" and "days after objects become concurrent" and we set both field to 1 day which is the minimum value.

This is what happened: An object was tagged on 01/26 around 18:34 GMT

On 01/26 in the PST morning, we ran aws s3api head-object --bucket bucketname --key KeyPath --profile xxxx and the header response says : { "AcceptRanges" : "bytes" "Expiration": "expiry-date="Sat, 27 Jan 2024 00:00:00 GMT" fule-id="expire tagKey:tagValue objects"" "LastModified": "Thu, 25 Jan 2024 18:34:03 GMT" .. .. }

on 01/29, we observed the object was deleted.

Questions are:

  • So far, based on our test, tag an s3 object does not change the object's Last Modified Date. Do you agree?
  • Based on the above scenario, it seems like the behavior is "object tagged on 01/25", take one day (which is entire 24 hours of 26th) to expire so the expiration date is set to 01/27 00:00:00 GMT. Am I correct?
  • Can you please explain the "Days after object creation" field in more details? How could it have anything to do with Expire current versions of objects? If an object was created 365 days ago, does not match any filter (in our case, a tag), but "days after object creation" was set to 1, will it still be deleted/expired?
  • Bottom line is the web console "days after object creation" field is actually just a "days take to expire an object" matching the following, instead of having anything to do with object's creation day? <LifecycleConfiguration> <Rule> <ID>Rule 1</ID> <Filter> <Prefix>logs/</Prefix> </Filter> <Status>Enabled</Status> <Expiration> <Days>1</Days> </Expiration> </Rule>
</LifecycleConfiguration>
  • Since we are not turning on s3 object versioning, my understanding is there is no non-current versions of objects, is there? Hence, we could actually choose not to pick the "Permanently delete non-current versions of objects". Am I correct?

Thank you!

asked 2 months ago126 views
1 Answer
1
Accepted Answer

Hello Kindly view the information below for your perusal:

  1. So far, based on our test, tag an s3 object does not change the object's Last Modified Date. Do you agree?

A - This is true, Amazon S3 automatically updates the last-modified field for object whenever it is created, updated (not it's metadata) or replaced.

  1. Based on the above scenario, it seems like the behavior is "object tagged on 01/25", take one day (which is entire 24 hours of 26th) to expire so the expiration date is set to 01/27 00:00:00 GMT. Am I correct?

A - This is correct. If the object was created, replaced or updated on the 25th of January, regardless of the time it was created, the day after creation counts the 24 hours of the next day which in this case would be January 26th from 00:00:00 up until the object is expired on 27th January 00:00:00 GMT.

  1. Can you please explain the "Days after object creation" field in more details?

A - Days after creating refers to the 24 hour periods that will pass after the day that object was created. If created on the 1st, days after creation will start counting from the 2nd midnight.

Q - How could it have anything to do with Expire current versions of objects? A - The term Current versions refer to the main version of many versions of an object and this applies in an versioned bucket.

In this case, you did mention that the bucket has versioning disabled therefore, the "Expire current versions" will apply to all the tagged objects in the bucket. You then need to specify how long you want to keep the objects before the lifecyccle expires the by specifying the days after creation.

Q - If an object was created 365 days ago, does not match any filter (in our case, a tag), but "days after object creation" was set to 1, will it still be deleted/expired?

A - When the "Days after creation" is set to 1 day and there are objects that are tagged with key value pair specified on lifecycle rule, those objects will be expired as long as 1 day has passed since the have been added to the bucket.

If there are objects that were created 365 days ago but are not tagged according to the lifecycle rule, those objects will not be expired as they do not meet the all the requirements of the rule.

  1. Since we are not turning on s3 object versioning, my understanding is there is no non-current versions of objects, is there? Hence, we could actually choose not to pick the "Permanently delete non-current versions of objects". Am I correct?

A - Yes this is correct, "Permanently delete noncurrent version" applies only to versioned bucket and/or buckets that had versioning enabled before then it was manually suspended. If the versioning status is "Disabled", the this option does not apply to objects in that bucket.

References [+]https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-expire-general-considerations.html [+]https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-set-lifecycle-configuration-intro.html

AWS
SUPPORT ENGINEER
TheLich
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions