スキップしてコンテンツを表示

Best way to exclude an object from s3 lifecycle rule

0

Hi there,

I want to create a lifecycle rule that deletes ALL objects in a bucket older than a month except the latest one. And I want to keep this latest backup forever until I manually remove it. I understand that I cannot exclude objects from lifecycle rules that match them. So, could you please suggest a workaround or the best way to implement this? E.g. manually copy or move this latest backup to other bucket, tag the objects to be deleted, use object lock, etc.

Thank you so much for your time and help. :)

質問済み 2年前2010ビュー

1回答
1

Hello.

Are the names of the objects obtained during backup the same?
If the names are the same, I think the easiest way is to enable versioning and create a lifecycle rule that deletes the old version after one month.
If the object name is different, I think you can create a Lambda function that tags the old object and set a lifecycle rule to delete the object with the target tag set.
https://docs.aws.amazon.com/AmazonS3/latest/userguide/lifecycle-configuration-examples.html#lifecycle-config-ex1

エキスパート

回答済み 2年前

エキスパート

レビュー済み 2年前

エキスパート

レビュー済み 2年前

  • Hi, Riku. The object names are different as they are creation date and time. For each customer, the backups are automatically created and uploaded to s3 every hour. Using the Lambda function, can I tag all objects except 3 latest objects/backups for each customer/prefix? These latest backups might be from a long time ago, e.g. 1 month ago, 3 years ago. Can I do that using a Lambda function? Thanks in advance.

  • I think it is possible if you just set tags on what is currently stored in S3. From now on, I think you can create a Lambda function that sets the tag on the previous object every time a new object is uploaded. I think it would be a good idea to record the latest object key in DynamoDB, etc., and then when a new object is uploaded to S3, set a tag on the object with the object key stored in DynamoDB.

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

関連するコンテンツ