Use S3 lifecycle policy to create a recycle bin

1

I am thinking to create a recycle bin mechanism for a versioned s3 bucket to prevent accidental deletion and modification of authorized users. The idea is 1) keep most recent 5 non-current revisions for 1 day; 2) any non-current version older than 2 days will be deleted.

The policies look like:

{
    "Rules": [
        {
            "ID": "Recyclebin_Part1",
            "Filter": {},
            "Status": "Enabled",
            "NoncurrentVersionExpiration": {
                "NoncurrentDays": 1,
                "NewerNoncurrentVersions": 5
            }
        },
        {
            "ID": "RecycleBin_Part2",
            "Filter": {},
            "Status": "Enabled",
            "NoncurrentVersionExpiration": {
                "NoncurrentDays": 2
            }
        }
    ]
}

However, looks like the second rule RecycleBin_Part2 was never applied. By checking at the object versions, there are always 5 non-current versions, even after a couple of days.

I could be wrong but does the first policy always win if both policies target (whole bucket) on the same scope and perform a same operation (expire objects) on the objects?

Is there a better way to implement this idea? A script to scan and purge non-current objects might not be a scalable option for buckets with millions of objects.

Thanks!

JM
已提問 2 年前檢視次數 155 次
沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南