Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS S3 : Do Lifecycle rules accept regex?

I have an s3 bucket with "folders" folder1, folder2, folder3, folder4. In folder2 and folder3 there is a "new" folder. I need to delete everything in "new", older than 1 day. Can I do that with a rule like /*/new/ ? Some guys say they have seen such rules work in the past, but that particular definition does nothing.

(In the real bucket there are folder1, folder2 ... folder3001 so I can't make rules for every folder, so please don't suggest that. The above example is for simplicity only.)

like image 238
ERIK_SON Avatar asked Sep 27 '16 05:09

ERIK_SON


People also ask

Which two types of actions can Lifecycle rules apply to an object?

A Lifecycle rule can apply to all or a subset of objects in a bucket based on the <Filter> element that you specify in the Lifecycle rule. You can filter objects by key prefix, object tags, or a combination of both (in which case Amazon S3 uses a logical AND to combine the filters).

Do S3 lifecycle rules apply retroactively?

Yes it's retroactive (i.e. all the things that are already there and match will get the rule). There may be a slight delay (i.e. rules will have day granularity and run on daily basis), but the rules will take effect immediately.

What is life cycle rule in S3?

An S3 Lifecycle configuration is an XML file that consists of a set of rules with predefined actions that you want Amazon S3 to perform on objects during their lifetime. You can also configure the lifecycle by using the Amazon S3 console, REST API, AWS SDKs, and the AWS Command Line Interface (AWS CLI).

What are the different types of actions in object lifecycle management in Amazon S3?

S3 Object Lifecycle Management Rules S3 Standard storage class –> other storage class. Any storage class –> S3 Glacier or S3 Glacier Deep Archive storage classes. S3 Intelligent-Tiering storage class –> S3 One Zone-IA storage class. S3 Glacier storage class –> S3 Glacier Deep Archive storage class.


1 Answers

The PUT livecycle API takes a "Prefix", which as the name says is a prefix, not a regex. http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTlifecycle.html

There is also a limit of 1000 rules per bucket. http://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html

You could change your folder structure so that keys look like "new/folderN".

like image 105
at0mzk Avatar answered Sep 18 '22 01:09

at0mzk