Amazon S3对象到期 [英] Amazon S3 object expiration

查看:332
本文介绍了Amazon S3对象到期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了很多有关如何过期(删除)亚马逊S3对象的信息,并尝试设置生命周期规则来做到这一点,但是并没有删除对象,想知道我做错了什么.

I read a lot about how to expire(delete) amazon S3 object and tried to setup lifecycle rule to do that, however the objects are not removed, wondering what i did wrong.

我在S3上的对象组织如下:

i have objects on S3 organized like this:

Amazon S3 > my-test-bucket > my-test-org > a.csv, 
                                           b.xml, 
                                           c.xsl...

我需要删除my-test-bucket中所有已存在365天的文件.有很多文件的使用期限已超过2年,因此使用此规则应删除那些文件.

i need to delete all those files in my-test-bucket if they are 365 days old. there are lots of files there more than 2 years old so with this rule those files should be removed.

在生命周期规则中,我指定添加过滤器以限制范围my-test-bucket,在到期"部分中,我选择了当前版本"和先前版本",

in the lifecycle rule, i specified adding filter to limit scope my-test-bucket, and in 'Expiration' section, i selected both 'Current version' and 'Previous versions',

  • 从创建对象开始的365天后过期对象的当前版本
  • 在365天后永久删除以前的版本,成为先前的版本
  • 该规则适用于前缀"my-test-bucket"

my-test-bucket没有启用版本控制.

my-test-bucket is not versioning-enabled.

完成所有这些操作后,我一直在等待,但什么都没发生.这些旧文件仍然在那里.我的问题是:

After all these are done, i kept waiting and waiting but nothing happened. those old files are still there. my questions are:

  1. 何时自动过期?每天午夜还是什么?
  2. 有没有可以按下以使其立即失效的按钮?
  3. 在我的情况下,我的文件位于my-test-org下,而不是my-test-bucket下,此规则仍然有效吗?我是否必须在规则中应用通配符以确保检查所有org文件夹中的所有文件?
  1. when does auto expire happens? every day at midnight or what?
  2. is there a button that i can push to make it expire objects right away?
  3. in my case, i have files under my-test-org instead of right under my-test-bucket, will this rule still work? do i have to apply wildcard in the rule to make sure it check on all files in all org folder?

谢谢

推荐答案

"该规则适用于前缀"my-test-bucket""

这是您的错误.前缀是指对象键的前缀.这不包括存储桶名称.

This is your error. The prefix refers to the object key prefix. This does not include the bucket name.

所需的前缀为my-test-org/.尾部的斜杠很重要,因为没有它,您的规则也将与其他键前缀匹配,例如my-test-organizationmy-test-organism,它们可能导致意外的匹配.

The prefix you want is my-test-org/. The trailing slash is important, because without it, your rule would also match other key prefixes, like my-test-organization and my-test-organism which can lead to unexpected matches.

请记住,S3中确实没有文件夹.对象键是字符串,用/分隔以表示文件夹层次结构,但是文件夹并不是真正的容器.出现在文件夹"bar"中的文件"foo.txt"实际上具有"bar/foo.txt"的对象键.

Remember that there are not really folders in S3. The object keys are strings, delimited by / to signify a folder hierarchy, but the folders are not really containers. A file "foo.txt" that appears in folder "bar" actually has an object key of "bar/foo.txt".

以伪代码表示的前缀匹配为

The prefix match, in pseudocode, is

if(left(object_key, len(prefix)) == prefix) { # rule matches

更改使用该前缀的规则,如果密钥的存在时间超过365天,则将删除每个密钥以my-test-org/开头的对象.当然,这包括所有子目录.

Changing the rule to use this prefix, every object with a key beginning with my-test-org/ will be deleted, if over 365 days old. This, of course, includes all subdirectories.

规则测试似乎在UTC午夜前后开始,而实际的清除工作在此后的某个时间开始.

Rule tests appear to start around midnight UTC and the actual purge starts some time after that.

这篇关于Amazon S3对象到期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆