Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using AWS S3 Object Lifecycle, how can I remove deleted objects

Tags:

amazon-s3

Is there a way I can use s3's object lifecycle to prune through current versioned objects and delete those objects premantely that have a deleted marker on them in lets say a month or a week? If there isn't, how is house cleaning performed on versioned buckets?

like image 810
David Avatar asked Dec 14 '14 10:12

David


People also ask

How do I delete items from my AWS S3?

To delete the object, select the object, and choose delete and confirm your choice by typing delete in the text field. On, Amazon S3 will permanently delete the object version. Select the object version that you want to delete, and choose delete and confirm your choice by typing permanently delete in the text field.

Which feature of S3 can automatically delete objects?

Object Expiration allows you to schedule removal of your objects after a defined time period.

Which AWS S3 service can be used to help prevent accidental deletion of objects?

S3 Object Lock can help prevent accidental or inappropriate deletion of data. For example, you could use S3 Object Lock to help protect your AWS CloudTrail logs.


1 Answers

This page describes object lifecycle management generically. This page describes lifecycle configuration more specifically.

You cannot do precisely what you want with S3's built-in lifecycle. With the versioning feature, there are two types of objects: the current version, and old non-current versions. The current version is the latest, most recently uploaded version of your object. For now, if the latest thing you've done to an object is cover it with a delete-marker, treat the delete-marker as the current version.

With S3's lifecycle, you can set up a rule to permanently delete non-current versions after X days. (You can also set up rules to move to glacier after X days.) But it sounds like what you're asking is for a rule where you can permanently delete non-current-but-only-if-the-current-is-a-delete-marker. This isn't natively supported.

If you want to only delete objects whose current version is a delete marker, you'll have to write your own listing agent to walk your bucket, enumerate these objects, and delete them yourself. There might be existing tools for this already; I haven't checked.

like image 91
sethwm Avatar answered Oct 21 '22 00:10

sethwm