내용으로 건너뛰기

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년 전2천회 조회

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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠