Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS S3 lifecycle rule on multiple folders

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?

like image 285
delned Avatar asked Aug 16 '16 08:08

delned


People also ask

Does S3 lifecycle delete folders?

The subfolders DO get deleted when the retention policy set to: "This rule applies to all objects in the bucket". Hopefully, an option will be added soon to AWS retention policy so that it can be set to no include Folders. Hope this helps !

How many folders can you have in S3 bucket?

There are no limits to the number of files/folders you can place in a bucket. You are however limited to 100 buckets per account.

Does S3 lifecycle apply to existing objects?

Lifecycle policies apply to both existing and new S3 objects, ensuring that you can optimize storage and maximize cost savings for all current data and any new data placed in S3 without time-consuming manual data review and migration.

Should I use folders in S3?

Using "folders" has no performance impact on S3, either way. It doesn't make it faster, and it doesn't make it slower. The value of delimiting your object keys with / is in organization, both machine-friendly and human-friendly.

How to apply lifecycle rules in AWS S3?

Login to the S3 in AWS Management Console. Navigate to the bucket that you want to apply Lifecycle rules. Click on the Lifecycle link on the right-hand side of the Properties tab, and click on “Add rule”. You can either apply the rule to the whole bucket or any folder (prefix). We selected cpimg/ to apply Lifecycle rules in this example.

What is rule 2 in AWS S3?

Rule 2 applies to objects with the key name prefix classB/. It directs Amazon S3 to transition objects to the S3 Standard-IA storage class 90 days after creation and delete them one year after creation. You might specify an S3 Lifecycle configuration in which you specify overlapping prefixes, or actions.

What is the S3 lifecycle configuration?

This section provides examples of S3 Lifecycle configuration. Each example shows how you can specify the XML in each of the example scenarios. Each S3 Lifecycle rule includes a filter that you can use to identify a subset of objects in your bucket to which the S3 Lifecycle rule applies.

Why does AWS S3 keep multiple versions of an object?

Also, S3 keeps multiple versions of the Object to achieve HA. Enabling or disabling versioning of one object within the bucket is optional. If you enable versioning, you can protect your objects from accidental deletion or being overwritten because you have the option of retrieving older versions of them.


1 Answers

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).

like image 79
matsev Avatar answered Nov 07 '22 13:11

matsev