S3 / Client / delete_bucket

delete_bucket#

S3.Client.delete_bucket(**kwargs)#

Deletes the S3 bucket. All objects (including all object versions and delete markers) in the bucket must be deleted before the bucket itself can be deleted.

Related Resources

See also: AWS API Documentation

Request Syntax

response = client.delete_bucket(
    Bucket='string',
    ExpectedBucketOwner='string'
)
Parameters:
  • Bucket (string) –

    [REQUIRED]

    Specifies the bucket being deleted.

  • ExpectedBucketOwner (string) –

    The account ID of the expected bucket owner. If the account ID that you provide does not match the actual owner of the bucket, the request fails with the HTTP status code 403 Forbidden (access denied).

    Note

    For directory buckets, this header is not supported in this API operation. If you specify this header, the request fails with the HTTP status code 501 Not Implemented.

Returns:

None

Examples

The following example deletes the specified bucket.

response = client.delete_bucket(
    Bucket='forrandall2',
)

print(response)

Expected Output:

{
    'ResponseMetadata': {
        '...': '...',
    },
}