Deleting a directory bucket - Amazon Simple Storage Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Deleting a directory bucket

You can delete only empty Amazon S3 directory buckets. Before you delete your directory bucket, you must delete all objects in the bucket and abort all in-progress multipart uploads.

To empty a directory bucket, see Emptying a directory bucket. To abort an in-progress multipart upload, see Aborting a multipart upload.

To delete a general purpose bucket, see Deleting a bucket.

After you empty your directory bucket and abort all in-progress multipart uploads, you can delete your bucket.

  1. Sign in to the Amazon Web Services Management Console and open the Amazon S3 console at

  2. In the left navigation pane, choose Buckets.

  3. Choose the Directory buckets tab.

  4. In the Directory buckets list, choose the option button next to the bucket that you want to delete.

  5. Choose Delete.

  6. On the Delete bucket page, enter the name of the bucket in the text field to confirm the deletion of your bucket.


    Deleting a directory bucket can't be undone.

  7. To delete your directory bucket, choose Delete bucket.

The following examples delete a directory bucket by using the Amazon SDK for Java 2.x and Amazon SDK for Python (Boto3).

SDK for Java 2.x
public static void deleteBucket(S3Client s3Client, String bucketName) { try { DeleteBucketRequest del = DeleteBucketRequest.builder() .bucket(bucketName) .build(); s3Client.deleteBucket(del); System.out.println("Bucket " + bucketName + " has been deleted"); } catch (S3Exception e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
SDK for Python
import logging import boto3 from botocore.exceptions import ClientError def delete_bucket(s3_client, bucket_name): ''' Delete a directory bucket in a specified Region :param s3_client: boto3 S3 client :param bucket_name: Bucket to delete; for example, 'doc-example-bucket--usw2-az1--x-s3' :return: True if bucket is deleted, else False ''' try: s3_client.delete_bucket(Bucket = bucket_name) except ClientError as e: logging.error(e) return False return True if __name__ == '__main__': bucket_name = 'BUCKET_NAME' region = 'us-west-2' s3_client = boto3.client('s3', region_name = region)

This example shows how to delete a directory bucket by using the Amazon CLI. To use the command replace the user input placeholders with your own information.

aws s3api delete-bucket --bucket bucket-base-name--azid--x-s3 --region us-west-2

For more information, see delete-bucket in the Amazon Command Line Interface.