alex-phillips
alex-phillips

Reputation: 868

Amazon S3 Delete Markers

I have web storage set up for some files in Amazon S3. I'm using its PHP SDK to manage these files. I have an automation script running to delete files from a certain bucket after a certain period of time. I've just realized that I don't believe it's actually deleting the files, but replacing them with a delete marker. When I use a program like Transmission (Mac) to view the bucket, it lists all files since 2013 when I set up the script. But if I go to the management interface in a browser, it only lists files as far back as the cutoff I have set in the script.

My question is: am I paying much more money for storage of these markers when I have no need for actually keeping any of these files? And how do I permanently delete these files? Everything I've found is that this is only an issue with versioned buckets, but this particular bucket is not versioned. According to the documentation, I need to include the version ID of the object in the delete call to delete the marker, but at this point, how do I retrieve that information since 'listObjects' does not return these.

If I use Transmission to pull down a 'deleted' file, the file still opens and functions as if it were never deleted.

Upvotes: 5

Views: 15857

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269320

If Versioning is enabled on an Amazon S3 bucket, then all uploads of an object to an existing key name will result in the creation of an additional version of the object. The prior versions will be kept on Amazon S3. Deleting an object will add a Delete Marker, so that the object appears to have been deleted, but prior versions are still available for download.

If a Bucket has Versioning enabled, you can view object versions and delete markers in the console:

  • Access your Bucket in the Amazon S3 console
  • Look for the Versions buttons at the top of the screen. It should have two buttons: Show, Hide
  • Selecting Show will display delete markers and all prior versions of objects

A simpler way to delete objects from Amazon S3 after a certain period of time is:

  • Select your Bucket
  • Open Properties
  • Click Lifecycle
  • Create a rule set to Permanently Delete n days after the object's creation date

Upvotes: 10

Related Questions