By using AWS re:Post, you agree to the Terms of Use

S3 Bucket Delete Marker Policy Not Working


Hi, I have a S3 bucket with a lifecycle policy and it was version enabled. The policy was to delete objects after 7 days and due to versioning the objects had a delete marker. Now I have created a new lifecycle policy around 3-4 days back to remove the delete markers permanently as I don't need the files anymore and when I checked the bucket today as well, the objects are still there. Please tell me how can I remove the objects as I have around 100 TB data and I cannot remove it manually. Please help me Thanks

asked 6 months ago279 views
2 Answers


If you would like to remove all objects inside bucket you can use EMPTY feature in S3 to clear all objects in S3:

You can empty a bucket's contents using the Amazon S3 console, AWS SDKs, or AWS Command Line Interface (AWS CLI). When you empty a bucket, you delete all the objects, but you keep the bucket. After you empty a bucket, it cannot be undone. When you empty a bucket that has S3 Bucket Versioning enabled or suspended, all versions of all the objects in the bucket are deleted.

aws s3 rm s3://bucket-name/doc --recursive

** Delete Markers:**

If you would like to use delete markers to delete all versions of the object you can use the below commnad

aws s3api delete-object --bucket DOC-EXAMPLE-BUCKET1 --key test.txt --version-id versionID

AWS Docs Information:

If you have any questions please let me know


answered 6 months ago

Use lifecycle policies to remove older versions leaving only delete markers and use rules to have them removed too. Checkout Example 7. Hope that helps

answered 6 months ago
  • Thanks Sandeep for your response. Just a quick question, if I set the policy to Permanently Delete Expired Marker Objects then it will not be touching any other object in the bucket except the ones with Delete Markers right?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions