AWS S3: Delete a file x days after last modification

0

I'm struggling with the following use case in AWS S3 and life cycle rules:

In my application, a user can ask for file deletion.

When it does i want to keep the file 90 days and then delete it.

I don't want to delete the file 90 days after the date it was created (uploaded)

For example:

I have a life cycle rule in my bucket that will expires files with tag "to_delete" 90 days after creation date.

I upload file for the first time in bucket: last modified date is today (creation date), let's say D1.

In 3 days i edit the file, i add the "to_delete" tag: last modified date is D1 + 3 days, let's say D3.

Will the life cycle rule apply 90 days from today (D1) or from today + 3 days (D3) ?

  • Have you enabled versioning? And is the modified object name going to remain the same?

  • No bucket versioning is not enabled and yes the modified object will still have the same name

已提问 2 年前1436 查看次数
2 回答
0

Hello,

I understand you have a question about S3 lifecycle policies.

According to the S3 Lifecycle Policy documentation on AWS Docs [1], you can use Expiration actions. These actions define when objects expire. Amazon S3 deletes expired objects on your behalf asynchronously. With S3 Lifecycle configuration rules, you can tell Amazon S3 to transition objects to less-expensive storage classes, or archive or delete them. However, this alone does not solve your problem since, as you said, policies only allow you to delete objects from its creation date.

Per rePost-User-2738569, this is where versioning comes in. If you set a lifecycle policy with bucket versioning enabled, every time a user changes an object, the object gets a new "version id". This becomes the newest version of the object and the main one that the user will see. You can set the number of days for when a object becomes noncurrent, and the number of newer versions to retain. That way, even though a number of objects are noncurrent, only the number of objects you specify will be retained.

Thus, you can set the number of days for expiration to be 90. You can set final deletion for 90 days this way as well.

已回答 2 年前
  • But the file will never be versioned, it's uploaded and then deleted but nothing happens between this two events. If versioning is enabled i will always have one version (current version) so if delete the file the problem remain the same ?

0

How about i add a to_delete tag and a to_delete metadata when the user wants to deletes the file. If my understanding is correct, if a file metadata is added aws creates a copy of the file which would resolves the problem of the creation date ?

已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则

相关内容