Deleting S3 objects
Sign up for FREE to access this course
Click the Sign Up button button below to create your free account and get instant access to this course. If you already have an account, simply click the Sign In button to get access.
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!
Sign up to access the rest of this lesson
You must either log in or sign up to access this lesson.