Search code examples
pythonamazon-s3lifecycleboto

Boto S3 Lifecycle expiration


I have an S3 bucket with multiple keys. I will be adding new keys each day. I would like to expire any keys older than x days (say 10).

My keys are date_based like this: program1_2014_06_24

I have created a lifecycle_rule like this:

life = boto.s3.lifecycle.Lifecycle()
life.add_rule('rule1', status='Enabled', expiration=10)
bucket.configure_lifecycle(life)

Does this take care of it? So, if I add 20 keys today, will they be deleted in 10 days? and the 30 keys I add tomorrow be deleted the day after that? In other words, do I need to add a new lifecycle rule each day, or just once

Sorry for the puzzlement, but the documentation I found on lifecycle is not too great.


Solution

  • That should take care of it. The code you show will set up an Expiration Lifecycle rule for that bucket and any object that is older than the expiration you specify will be queued for removal.