How to Manage S3 Object LifeCycle (`Object Expiration`) Configuration

How to Manage S3 Object LifeCycle (`Object Expiration`) Configuration

In this guide, we describe how to manage the life cycle configuration of a S3 bucket including adding, viewing, deleting, and disabling object expiration rules. Some objects store in an AWS S3 storage bucket might have a well-defined life time. For example support an e-commerce month deal with specific that are valid only for this specific month and should be deleted/renewed for the next month’s deal. For such cases, you can set the `Object Expiration` date, once expired Amazon S3 will automatically delete it.

Once a S3 object reaches the end of its life time, AWS system queues it for deletion and will remove it asynchronously so there may be a lag between the expiration time and deletion time. Amazon S3 calculates expiration time by adding the expiration period specified in the rule to the object creation time and rounding the resulting time to the next day midnight UTC. For example, if an object was created on 7/15/2021 9:30 am UTC and the expiration period set to three days, then the expiration date of the object would be calculated as 7/19/2021 00:00 UTC. Note that you will not be charged for storage the time associated with an object that has expired.

The next steps will show you how to manage a S3 storage object Lifecycle:

1. Login to your AWS account console and enter the S3 section.

2.  Select the bucket for which you want to set the expiration rule -

3.  Select `Lifecycle` tab on bucket properties bottom pane and click `Add Rule`

4. Set the expiration rule for a specific folder.

5.  `Enabled` check box should be selected and the name is for reference only and auto generated. The prefix specifies the file name - starting with that prefix.

6.  The new rule is applied to all objects of that folder.

8.  Select Object Properties to view the expiration time of the object.


[Newvem S3 analysis helps identify storage migration opportunities such as AWS RRS and Glacier Archive. Check Newvem S3 Analytics Tool]


The next steps describe how to set the expiration time for a specific bucket..

9.  As shown above, we have set the expiration rule for Sample1.txt as 2 days. All files named as Sample1.txt in this bucket will have this rule. When you select the Sample1.txt file property, it will show rule name and expiration time as below.

11.  At the same time check the expiration rule for index.html. Since we have not applied any expiration rule, it will have the expiry date as None.

12.  Now we will set the rule for complete bucket.

13.  To set the rule for bucket, keep the prefix part as blank. It implies to whole bucket in this case.

14.  We have set object expiration of bucket to 30 days. It will prompt you message that this policy applies to all objects of your bucket. If there is any existing rule in the bucket for particular object, it will not allow you to apply bucket level expiration. You have to delete all rules before applying bucket level rule.

15.  As shown in above image, we have deleted all existing object / folder rules.

16.  Now check the index.html object.  It will also have expiration rule and it will expire in 30 days.

17.  Since we have removed all rules for the objects as mentioned in step#23, now all objects will have expiration rule of 30 days. They may have different expiration date since their creation time can be different.

18.  As shown above the ‘Sample2.txt’ has now expiration of 30 days instead of 1 day we configured in step#15.


[Amazon S3 User? Newvem dashboard amplifies visibility and the cost breakdowns of your S3 footprint with drill downs from a consolidated view to the buckets' structure and to object profiles. Learn More]


Keywords: Amazon AWS elastic cloud services, S3 Bucket, How-to Guide, S3 Storage, S3 Bucket, Bucket Expiration Configuration, S3 Simple Storage

You must be to post a comment.

* As a bonus, you'll receive our weekly newsletter!

Hitchhiker's Guide to The Cloud

Newvem's eBook for Cloud Operations