How To Expire Objects/Files in S3 Bucket using LifeCycle Rules

In this video, let’s take a look at how to automatically clean obsolete objects from your s3 bucket using LifeCycle rule.

This tutorial builds on my previous two videos and in those two tutorials I show  how to setup  serverless Email for a custom domain using AWS services.

I used AWS SES, that’s Simple Email Service as a SMTP endpoint for your website or newsletter distribution, AWS S3 to store the incoming emails. I also setup an AWS Lambda function to forward those incoming emails stored in S3 to my gmail destination.

If we are forwarding those emails then we also need to clean up the S3 bucket of old emails otherwise they will take up storage and costs. So with Lifecycle rule you can routinely have AWS delete older objects/files automatically.


  1. Create a Lifecycle rule in the S3 bucket to remove old emails.
    1. Goto S3 bucket
    2. Click on Management
    3. Click on Create lifecycle rule
    4. Give a name for the Rule
    5. Choose scope to be All objects and acknowledge **
    6. For Actions select Expire, Permanently Delte and Delete expired markers
    7. Give 5, 5, 5 for the days.
    8. Click Create Rule

All videos tutorials on the website as well as the YouTube channel aim to provide a simplified process for a specific scenario; there could be many different factors and unique use cases you may have. The tutorials may not cover every situation; so treat is as a starting point or learning concept to apply to your unique situations, and consider this inspiration but not prescription or explicit direction.

Scroll to Top