简体   繁体   English

前缀嵌套时无法在s3存储桶上应用生命周期策略

[英]Unable to apply lifecycle policy on s3 bucket when prefix is nested

I have applied a lifecycle policy on s3 bucket name ( async-download ) with prefix tmp_active_job_storage/ 我已对前缀为tmp_active_job_storage/ s3存储桶名称( async-download )应用了生命周期策略

This works as expected when prefix is immediately after bucket name. 当前缀位于存储桶名称之后时,这可以按预期工作。

Below is the object key: 以下是对象键:

https://async-download.s3.amazonaws.com/tmp_active_job_storage/file_name.png

生命周期配置

But this is not working when I introduced one folder between the bucket name and prefix. 但这在我在存储桶名称和前缀之间引入一个文件夹时不起作用。 Folder name before prefix is dynamic key I can't apply rule on it. 前缀之前的文件夹名称是动态密钥,我无法对其应用规则。

Now modified object key is: 现在修改的对象键为:

https://async-download.s3.amazonaws.com/1111-2222-3333-4444/tmp_active_job_storage/file_name.png

In API documentation PUT Bucket lifecycle - Amazon Simple Storage Service I can not see any support for prefix as regex. 在API文档PUT存储桶生命周期-Amazon Simple Storage Service中,我看不到对前缀的任何支持(如正则表达式)。

Is there any way to achieve this? 有什么办法可以做到这一点?

Folder name before prefix is... 前缀前的文件夹名称是...

By definition, nothing can come "before" a key prefix. 根据定义,键前缀“之前”没有任何内容。 The prefix is the beginning of the object key. 前缀是对象键的开头。 S3 lifecycle rules only support exact string matches, not regexes. S3生命周期规则仅支持完全匹配的字符串,不支持正则表达式。

You need a common prefix at the beginning of all the object keys, or you need to dedicate a bucket to store these temporary files (and nothing else) so that the lifecycle policy can be applied to the entire bucket. 您需要在所有对象键的开头添加一个公共前缀,或者您需要专用存储桶来存储这些临时文件(而不是其他任何东西),以便可以将生命周期策略应用于整个存储桶。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM