6
votes

I have a bucket that contains many folders and I would like to apply a lifecycle rule only fore some folders within the bucket. It's possible to apply an AWS S3 lifecycle rule on multiple folders(PREfixes) within a bucket?

For example I have a bucket s3://mybucket that contains folder1, folder2 folder3, folder4. I would like to send to Glacier only folder1 and folder 4.

My question is: I need to create new rule for every folder(prefix) or it is a possibility to insert all of them in a single rule?

1

1 Answers

9
votes

Copied from the S3 Managing Lifecycle Configuration:

You can define a rule for all objects or a subset of objects in the bucket (by specifying the key name prefix).

In other words, a rule applies to all objects that share the same prefix. If you have many different prefixes (such as folder1, folder2, etc) you must copy the rule and change the prefix accordingly. Alternatively, you can add a new common prefix (e.g. send-to-glacier/folder1, send-to-glacier/folder2 and then create a new rule for the send-to-glacier prefix).