The following post is a short guide on how to expire Amazon S3 objects by means of defining a simple lifecycle rule. In this tutorial, we’ll be deleting all files in the bucket that are older than 30 days.
- Log in to your Amazon S3 console, open S3 bucket you want to have your old files deleted from and click on “Add lifecycle rule”:
- Create a new lifecycle rule, call it: cleanup (or something you can easily identify in the future):
- Configure Transitions:
- Configure Expiration to your own rule. In my case, I am expiring files 30 days after their creation and removing them once for all 1 day later. Or in other words: Removing all files in the bucket that are older than 30 days into the trash, and deleting them permanently a day after they were put into the trash.
- Double check the summary to make sure everything is correctly setup and save the new ‘cleanup’ rule:
- New ‘cleanup’ rule should be created now: