Skip Certain folders in S3 Lifecycle Policy


I want to apply a deletion rule to my whole bucket to delete all objects that are older than 2 weeks. But my bucket has certain folders that need to be skipped. So is it possible via S3 lifecycle management to skip certain folders and delete rest of the stuff that is older than 2 weeks?

Here is my current bucket structure

I want to skip folder 4 and 6 and want to delete stuff in all other folders that are 14 days old.

Can someone tell me if its possible via AWS S3 Lifecycle management?


Yes you can. Lifecycle Rule supports prefix/tag to filter what you want to apply the rule.
You need to define which you want to delete except others.

To apply this lifecycle rule to all objects with a specified name
prefix (i.e., objects whose name begins with a common string), type in
a prefix. You can also limit the lifecycle rule scope to one or more
object tags. You can combine a prefix and tags. For more information
about object name prefixes, see Object Keys in the Amazon Simple
Storage Service Developer Guide. For more information about object
tags, see Object Tagging in the Amazon Simple Storage Service
Developer Guide

Leave a Reply