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:
Select “Management” and click on “Add lifecycle rule”:
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:
From the “Transitions” section, configure the transition section, by selecting to expire the current version of the object after 30 days:
Review the configuration:
When you select “Save”, you should be returned to the following section:
Housecleaning on your S3 Bucket
Now 30 days after you created objects on AWS S3, they will be deleted.