Skip to main content

DeleteBucket

DeleteBucket removes a bucket from your account. The bucket has to be empty first - no objects, no old versions and no delete markers - which keeps a bucket that still holds data from disappearing by accident. Once deleted, the bucket is gone for good, and its name is free for anyone to take straight away.

danger

A deleted bucket cannot be restored. Its name becomes available to every STRG customer at once, so it may not be possible to get it back. An access key limited to the bucket never reaches it again - not even if a bucket with the same name is created later.

Good to know on STRG
  • Every bucket keeps every version, so "empty" includes old versions and delete markers too - Emptying a bucket shows how to clear them.
  • Deleting a bucket takes an access key for all buckets.
  • A bucket in another region than the endpoint's is answered with 404 NoSuchBucket rather than a redirect, so each request goes to the bucket's own regional endpoint.
  • A deletion that takes longer than expected answers 503 SlowDown and finishes on its own.
  • x-amz-expected-bucket-owner is welcome and has nothing to check: a key only ever reaches buckets of its own account.

When you'd use it​

  • Cleaning up after tests. A CI pipeline that creates a fresh bucket for each run can empty and delete it at the end, so test data does not pile up as stored data.
  • Retiring a project. When an app or a client project is wound down, a clean-up script can empty its bucket and then delete it, so nothing stays behind and nothing more is billed for it.
  • An agent tidying up after itself. An AI agent that set up a scratch bucket for a task can delete it once the task is done - with a human confirming the deletion first, unless its key allows it to act without confirmation.

Request​

DELETE / HTTP/1.1
Host: my-bucket.s3.eu-central-1.strg.com
Authorization: AWS4-HMAC-SHA256 Credential=...
x-amz-date: 20260926T120000Z
x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

The path-style form is DELETE /my-bucket on s3.eu-central-1.strg.com. The request goes to the bucket's own region - Addressing explains both forms.

Permissions​

The access key needs Delete buckets (buckets:delete), a permission only a key for all buckets can hold. A key limited to certain buckets is answered with 403 AccessDenied. Access keys has the details.

An AI agent connected through the MCP server with a key that does not hold Act without confirmation (mcp:skip-confirmation) asks you to confirm every bucket deletion before it runs - Confirmation explains how that works.

URI parameters​

NameTypeRequiredDescription
BucketStringYesThe bucket to delete.

Request headers​

NameTypeRequiredDescription
x-amz-expected-bucket-ownerStringNoWelcome, and has nothing to check: an access key only ever reaches its own account's buckets.

Request body​

None.

Response​

A successful delete answers 204 No Content with no body.

Response headers​

NameDescription
x-amz-request-idThe request ID, handy for support requests.

Response body​

None.

Errors​

These are the errors a bucket deletion can return, and the situation behind each one.

CodeHTTP statusWhen
BucketNotEmpty409The bucket still holds an object, an old version or a delete marker. Emptying a bucket shows how to clear them.
NoSuchBucket404There is no bucket of that name of yours in the endpoint's region - it does not exist, belongs to someone else, or is in another region.
AccessDenied403The access key does not hold Delete buckets, or is limited to certain buckets.
InvalidAccessKeyId403The access key does not exist, has expired or been revoked, or it is not yet usable in a region where you already store data - a key created a moment ago, which works shortly after.
SignatureDoesNotMatch403The request signature does not match.
RequestTimeTooSkewed403The request time is more than 15 minutes from the server's.
AuthorizationHeaderMalformed400The signature's credential scope names a region other than the endpoint's.
NotImplemented501The request carries a query parameter this operation does not take.
SlowDown503The deletion is taking longer than expected. It is still in progress and finishes on its own. A retry after the Retry-After interval while it is still running waits for the same deletion rather than starting another, and answers 204 when it finishes. A retry after it has finished answers 404 NoSuchBucket, because the bucket is gone.
ServiceUnavailable503A temporary failure, or another change to the same bucket is still finishing. Nothing was deleted, and the same request can simply be sent again.

Emptying a bucket​

Every bucket keeps every version of every object, so deleting objects by key only adds delete markers - the bucket still holds the old versions. Emptying it means deleting each version and each delete marker by its versionId: ListObjectVersions lists them, and DeleteObjects deletes up to 1,000 per request. A version locked by Object Lock keeps the bucket from being deleted until the version's lock ends and it is deleted.

empty_bucket.py
import boto3

s3 = boto3.client(
"s3",
endpoint_url="https://s3.eu-central-1.strg.com",
region_name="eu-central-1",
)

paginator = s3.get_paginator("list_object_versions")
for page in paginator.paginate(Bucket="my-bucket"):
entries = page.get("Versions", []) + page.get("DeleteMarkers", [])
if entries:
s3.delete_objects(
Bucket="my-bucket",
Delete={
"Objects": [
{"Key": entry["Key"], "VersionId": entry["VersionId"]}
for entry in entries
],
"Quiet": True,
},
)

Deleting a version is permanent too, so it is worth double-checking the bucket name before running this.

Differences from Amazon S3​

AspectAmazon S3STRG
What must be emptyEvery object, and every version and delete marker if versioning was ever enabledEvery object, version and delete marker - every bucket keeps every version
Access key scopeAny identity with s3:DeleteBucket on the bucketA key for all buckets holding Delete buckets
Bucket in another region301 redirect with x-amz-bucket-region404 NoSuchBucket. The bucket's own regional endpoint is the one that deletes it.
A deletion still in progressNot applicable503 SlowDown with Retry-After. The deletion finishes on its own; a retry while it runs waits for it, and one after it finished is 404 NoSuchBucket.
Access keys limited to the bucketPolicies naming the bucket apply to a re-created bucket of the same nameA key limited to the bucket never reaches a re-created bucket of the same name. A new key scoped to the new bucket reaches it.
x-amz-expected-bucket-ownerChecked against the bucket ownerWelcome, with nothing to check

Examples​

Deleting the empty bucket my-bucket:

aws s3api delete-bucket \
--bucket my-bucket \
--endpoint-url https://s3.eu-central-1.strg.com \
--region eu-central-1
View as Markdown