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.)
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).
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.
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).
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.
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With