跳过 S3 生命周期策略中的某些文件夹

Skip Certain folders in S3 Lifecycle Policy

我想对我的整个存储桶应用删除规则,以删除超过 2 周的所有对象。但是我的存储桶中有某些需要跳过的文件夹。那么是否可以通过 S3 生命周期管理跳过某些文件夹并删除其他超过 2 周的内容?

这是我当前的存储桶结构

- example-bucket.com
    - folder 1
        - images
            - 1. jpg
        - videos
            - 1.mp4
            - 2.flv
    - folder 2
        - images
            - 1.jpg
    - folder 3
        - videos
            - 1.mp4
    - folder 4 (Should not be deleted)
        - content
        - folders
    - folder 5  
        - images
            - 1. jpg
        - videos
            - 1.mp4
            - 2.flv
    - folder 6 (Should not be deleted)
        - content
        - folders

我想跳过文件夹 4 和 6,并想删除所有其他文件夹中已存在 14 天的内容。

有人可以告诉我是否可以通过 AWS S3 生命周期管理吗?

是的,你可以。 Lifecycle Rule 支持prefix/tag 过滤你要应用的规则。
您需要定义除其他以外要删除的内容。
Reference:

To apply this lifecycle rule to all objects with a specified name prefix (i.e., objects whose name begins with a common string), type in a prefix. You can also limit the lifecycle rule scope to one or more object tags. You can combine a prefix and tags. For more information about object name prefixes, see Object Keys in the Amazon Simple Storage Service Developer Guide. For more information about object tags, see Object Tagging in the Amazon Simple Storage Service Developer Guide

这真的很令人沮丧,但如果不在存储桶中添加您想要存档或删除的每个前缀或标记您想要删除的所有内容,这是不可能的,所以如果您要向存储桶添加新文件夹,您将不得不确保它们符合前缀或被标记,这使得维护成为噩梦。如果您可以添加异常标记,情况会简单得多,特别是如果您想要存储桶中的自述文件描述其中未归档的内容。