Why can't I delete my S3 bucket using the Amazon S3 console or AWS CLI, even with full or root permissions?

Last updated: 2018-06-15

I'm trying to delete an Amazon Simple Storage Service (S3) bucket using the Amazon S3 console or AWS Command Line Interface (AWS CLI), and I have full or root permissions to the bucket. However, my delete request fails and the bucket is still available. How can I delete the bucket?

Short description

You can't delete an S3 bucket using the Amazon S3 console if the bucket contains 100,000 or more objects. You can't delete an S3 bucket using the AWS CLI if versioning is enabled. For more information, see Deleting or Emptying a Bucket.

To delete an S3 bucket in either scenario, first suspend versioning (if enabled), and then set up lifecycle rules to expire objects in the bucket after one day. After the objects are deleted, you can delete the bucket.


Warning: The following procedure permanently deletes any data in your S3 bucket. Data deleted and removed from a bucket can't be recovered. Before you proceed, review all of the objects and data in the bucket to be sure that they are no longer needed.

Follow these steps to suspend versioning and then set up lifecycle rules to delete objects in the bucket:

  1. Open the Amazon S3 console.
  2. Open the bucket that you want to delete by choosing the bucket's name.
  3. If versioning is enabled, suspend versioning on the bucket.
  4. Choose the Management view, and then choose Lifecycle.
  5. Choose + Add lifecycle rule.
  6. For Enter a rule name, type a name for the lifecycle rule.
  7. To run the rule on the entire bucket, leave Add filter to limit scope to prefix/tags blank, and then proceed to step #8. To run the rule on a certain prefix, enter the prefix under Add filter to limit scope to prefix/tags.
  8. Choose Next.
  9. For Configure transitions, leave fields blank, and then choose Next.
  10. For Configure expiration, select both Current version and Previous versions.
  11. For Expire current version of the object, type 1 to specify After 1 days from object creation.
  12. For Permanently delete previous versions, type 1 to specify After 1 days from becoming a previous version.
  13. Select Clean up incomplete multipart uploads. Then, type 1 to specify After 1 Days from start of upload.
  14. Choose Next.
  15. Choose Save.
  16. If you had versioning enabled on the bucket, repeat steps #4-9. Then, for Configure expiration, select only Clean up expired object delete markers, and then save the new rule. Note: If you receive the error message "This rule has prefix(es) that are overlapping with (previous_rule_name)," you can still save the rule.

The lifecycle rules run around midnight Universal Coordinated Time (UTC). After the lifecycle rules run, the objects aren't deleted immediately, but they are marked for deletion and you no longer are charged for those objects. For more information, see Configuring Object Expiration.

If there are a large number of objects in the bucket, they might still appear in the Amazon S3 console for a few days, particularly for buckets that had versioning enabled. If the bucket had versioning enabled, delete markers are created after the current versions of objects are deleted. After the delete markers are at least one day old, the lifecycle rules clean up the delete markers as well. It might take a few days for the delete markers to age past one day old, and then for the lifecycle rules to detect their age and remove them.

After the objects are fully deleted (including delete markers), you can delete the bucket.