Deleting S3 objects
Server Academy Members Only
Sorry, this lesson is only available to Server Academy members. Create a free account now to get instant access to this and more free courses. Click the Sign Up Free button below to get access to our free courses now, or sign in if you have an account.
There are no resources for this lesson.
To delete an object, first, choose the bucket that contains the object you want to delete. In my case, I will be selecting the myfirstbucket129:
Next we should see if we have bucket versioning enabled or not. We can do that by going to the properties tab and scrolling down to note if we have bucket versioning enabled or not for this bucket.
Once we've done that, we can go back to the objects tab and select the object and choose delete:
If you are deleting an object from a versioning-enabled bucket with versioning off, Amazon S3 will create a delete marker. To permanently delete the object, type "delete" in the text field and confirm your choice:
In case you didn't know, here is a quick explanation of what a delete marker is:
A delete marker in Amazon S3 is a placeholder for a versioned object that was named in a DELETE request. It allows Amazon S3 to behave as if the object has been deleted, even though it is still stored in the bucket.What is an AWS S3 Delete Marker?
If you are deleting an object from a versioning-enabled bucket with versioning on, Amazon S3 will permanently delete the object version.
To delete the object, select the object version that you want to delete and choose delete. Then, confirm your choice by typing "delete" in the text field.
Once you have deleted the object, you will see a success message stating the object was deleted:
Recovering deleted objects
It's important to note that deleting an object from a bucket is permanent and cannot be undone unless you have bucket versioning enabled. To recover an S3 object that you have deleted when the bucket has versioning enabled, browse to the folder where the deleted object was located.
Click Show versions, thenclick the checkbox next to the Delete Marker and finally click the Delete button to remove the marker:
Next, you'll need to confirm you want to delete the marker by entering permanently delete and clicking Delete objects:
In order to delete a delete marker, you need the s3:DeleteObjectVersion permission and must use the AWS account that owns or created the bucket.Permissions Requirement
Also, it's important to note that you can't use the Amazon S3 console to undelete folders. To do so, you must use the AWS CLI or the AWS SDK.
Now if we go back to the S3 bucket and turn off Show versions we will see our S3 object has been restored.
That's it! Now you know how to use the Amazon S3 console to delete a single object from a bucket. The moral of the story is, turn on bucket versioning! Happy deleting!
Server Academy Members Only
Want to access this lesson? Just sign up for a free Server Academy account and you'll be on your way. Already have an account? Click the Sign Up Free button to get started..