When you delete an object in a versioned bucket, the object is not deleted. A delete marker is placed on that object. You can still access the file if you click on show versions.
As the arrow points out, there is a delete marker placed on the object. You’re still getting charged for that object’s and it’s versions(if there’re any). So how do you actually delete an object from a versioned bucket. Let’s do a simple lab.
Step 1: Create a S3 bucket, give it a unique name. Click next
Step 2: Click on the versioning box and choose Enable Versioning and Save. Click Next
Step 3: Click Next and Create Bucket
Now we have our bucket ready.
Step 4: Create a .txt file on the local machine. Write a line “Hello World” or anything.
Step 5: Upload it to S3.
Step 6: Edit the text file and add a line.
Step 7: Upload the edited file to S3.
Notice that you only see only 1 version of the file. This is the latest version.
Step 8: Navigate to the Versions tab and click on show.
Step 9: Notice the 2 versions and the size difference.
Step 10: Go back to the normal view by clicking the hide button on the Versions tab.
Step 11: Delete the file.
When you delete a file from a versioned bucket, It’s not deleted. A delete Marker is written as a file. In the normal view we will see there is no file. (If you have more than 1 object you may see other undeleted files still there)
Step 12: Click show versions again and you’ll see that there is a delete marker present. But you still have 2 versions of the file. This is useful for preserving all file versions and accidental deletion.
Step 13: Delete the delete marker.
Step 14: Go back to the Hide Versions tab and you’ll see your file again.
Step 15: Now let’s delete the file again.
Step 16: Go to show versions. Delete the versions of the file individually. This is how you delete a versioned object.
Step 17: Finally let’s delete the delete marker as well.
Deleting a versioned object puts a delete marker. The object is not deleted.
To delete the files permanently:
Delete any file versions (backups of S3 objects) in versioning-enabled buckets. Deleting an S3 object doesn’t automatically delete all versions. This is an important step to consider when you want to cut storage cost. You may not be aware that there are several versions of the file under the delete marker. Make sure you delete unwanted versions or archive them to Glacier.