Ruan Bekker's Blog

From a Curious mind to Posts on Github

Expire Objects in AWS S3 Automatically After 30 Days

In AWS S3 you can make use of lifecycle policies to manage the lifetime of your objects stored in S3.

In this tutorial, I will show you how to delete objects automatically from S3 after 30 days.

Navigate to your Bucket

Head over to your AWS S3 bucket where you want to delete objects after they have been stored for 30 days:

0400F9CB-9223-4FDF-8FA5-D0BC1FA8EB71

Lifecycle Policies

Select “Management” and click on “Add lifecycle rule”:

9BB26C7C-F251-45C4-AE44-A34459BD0F4B

Set a rule name of choice and you have the option to provide a prefix if you want to delete objects based on a specific prefix. I will leave this blank as I want to delete objects in the root level of the bucket. Head to next on the following section:

AEF8B151-3FA8-454F-AC71-778A531BD1EE

From the “Transitions” section, configure the transition section, by selecting to expire the current version of the object after 30 days:

2B395671-A4C0-4E5A-82E7-00EE6579DB5A

Review the configuration:

F7F8E800-62FF-4156-B506-5FB9BCC148E0

When you select “Save”, you should be returned to the following section:

8421EBCE-9503-4259-92AA-DB66C6F532AF

Housecleaning on your S3 Bucket

Now 30 days after you created objects on AWS S3, they will be deleted.