You can delete an empty Amazon S3 general purpose bucket. For information about emptying a general purpose bucket, see Emptying a general purpose bucket.
You can delete a bucket by using the Amazon S3 console, the AWS Command Line Interface (AWS CLI), the AWS SDKs, or the Amazon S3 REST API.
Important
Before deleting a general purpose bucket, consider the following:
-
general purpose bucket names are unique within a global namespace. If you delete a bucket, be aware that another AWS account can use the same general purpose bucket name for a new bucket and can therefore potentially receive requests intended for the deleted bucket. If you want to prevent this, or if you want to continue to use the same bucket name, don't delete the bucket. We recommend that you empty the bucket and keep it, and instead, block any bucket requests as needed. For buckets no longer in active use, we recommend emptying the bucket of all objects to minimize costs while retaining the bucket itself.
-
When you delete a general purpose bucket, the bucket might not be instantly removed. Instead, Amazon S3 queues the bucket for deletion. Because Amazon S3 is distributed across AWS Regions, the deletion process takes time to fully propagate and achieve consistency throughout the system.
-
If the bucket hosts a static website, and you created and configured an Amazon Route 53 hosted zone as described in Tutorial: Configuring a static website using a custom domain registered with Route 53, you must clean up the Route 53 hosted zone settings that are related to the bucket. For more information, see Step 2: Delete the Route 53 hosted zone.
-
If the bucket receives log data from Elastic Load Balancing (ELB), we recommend that you stop the delivery of ELB logs to the bucket before deleting it. After you delete the bucket, if another user creates a bucket using the same name, your log data could potentially be delivered to that bucket. For information about ELB access logs, see Access logs for your Classic Load Balancer in the User Guide for Classic Load Balancers and Access logs for your Application Load Balancer in the User Guide for Application Load Balancers.
Troubleshooting
If you are unable to delete an Amazon S3 general purpose bucket, consider the following:
-
Make sure that the bucket is empty – You can delete buckets only if they don't have any objects in them. Make sure that the bucket is empty. For information about emptying a bucket, see Emptying a general purpose bucket.
-
Make sure that there aren't any access points attached – You can delete buckets only if they don't have any S3 Access Points or Multi-Region Access Points attached within the same account. Before deleting the bucket, delete any same-account access points that are attached to the bucket.
-
Make sure that you have the
s3:DeleteBucket
permission – If you can't delete a bucket, work with your IAM administrator to confirm that you have thes3:DeleteBucket
permission. For information about how to view or update IAM permissions, see Changing permissions for an IAM user in the IAM User Guide. For troubleshooting information, see Troubleshoot access denied (403 Forbidden) errors in Amazon S3. -
Check for
s3:DeleteBucket Deny
statements in AWS Organizations service control policies (SCPs) and resource control policies (RCPs) – SCPs and RCPs can deny the delete permission on a bucket. For more information, see service control policies and resource control policies in the AWS Organizations User Guide. -
Check for
s3:DeleteBucket Deny
statements in your bucket policy – If you haves3:DeleteBucket
permissions in your IAM user or role policy and you can't delete a bucket, the bucket policy might include aDeny
statement fors3:DeleteBucket
. Buckets created by AWS Elastic Beanstalk have a policy containing this statement by default. Before you can delete the bucket, you must delete this statement or the bucket policy.
Prerequisites
Before you can delete a general purpose bucket, you must empty it. For information about emptying a bucket, see Emptying a general purpose bucket.
To delete an S3 bucket
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/
. -
In the left navigation pane, choose General purpose buckets.
-
In the buckets list, select the option button next to the name of the bucket that you want to delete, and then choose Delete at the top of the page.
-
On the Delete bucket page, confirm that you want to delete the bucket by entering the bucket name in the text field, and then choose Delete bucket.
Note
If the bucket contains any objects, empty the bucket before deleting it by choosing the Empty bucket button in the This bucket is not empty error alert and following the instructions on the Empty bucket page. Then return to the Delete bucket page and delete the bucket.
-
To verify that you've deleted the bucket, open the General purpose buckets list and enter the name of the bucket that you deleted. If the bucket can't be found, your deletion was successful.
The following example shows how to empty and delete a general purpose bucket by using the AWS SDK for Java. The code first deletes all objects in the general purpose bucket, and then it deletes the bucket.
For examples in other languages, see Use DeleteBucket with
an AWS SDK or CLI in the Amazon Simple Storage Service API Reference. For information
about using other AWS SDKs, see Tools for Amazon Web
Services
You can delete a general purpose bucket that contains objects with the AWS CLI if the bucket doesn't have versioning enabled. When you delete a bucket that contains objects, all the objects in the bucket are permanently deleted, including objects that have been transitioned to the S3 Glacier Flexible Retrieval storage class.
If your bucket doesn't have versioning enabled, you can use the rb
(remove
bucket) AWS CLI command with the --force
parameter to delete the bucket and all the objects
in it. This command deletes all the objects first and then deletes the bucket.
If versioning is enabled, using the rb
command with the
--force
parameter doesn't delete versioned objects, so the bucket
deletion fails because the bucket isn't empty. For more information about deleting
versioned objects, see Deleting object
versions.
To use the following command, replace
with the name of the
bucket that you want to delete:amzn-s3-demo-bucket
$
aws s3 rb s3://amzn-s3-demo-bucket
--force
For more information, see Using High-Level S3 Commands with the AWS Command Line Interface in the AWS Command Line Interface User Guide.