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.
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.
- 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 NoSuchBucketrather than a redirect, so each request goes to the bucket's own regional endpoint. - A deletion that takes longer than expected answers
503 SlowDownand finishes on its own. x-amz-expected-bucket-owneris 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
| Name | Type | Required | Description |
|---|---|---|---|
Bucket | String | Yes | The bucket to delete. |
Request headers
| Name | Type | Required | Description |
|---|---|---|---|
x-amz-expected-bucket-owner | String | No | Welcome, 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
| Name | Description |
|---|---|
x-amz-request-id | The 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.
| Code | HTTP status | When |
|---|---|---|
BucketNotEmpty | 409 | The bucket still holds an object, an old version or a delete marker. Emptying a bucket shows how to clear them. |
NoSuchBucket | 404 | There 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. |
AccessDenied | 403 | The access key does not hold Delete buckets, or is limited to certain buckets. |
InvalidAccessKeyId | 403 | The 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. |
SignatureDoesNotMatch | 403 | The request signature does not match. |
RequestTimeTooSkewed | 403 | The request time is more than 15 minutes from the server's. |
AuthorizationHeaderMalformed | 400 | The signature's credential scope names a region other than the endpoint's. |
NotImplemented | 501 | The request carries a query parameter this operation does not take. |
SlowDown | 503 | The 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. |
ServiceUnavailable | 503 | A 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.
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
| Aspect | Amazon S3 | STRG |
|---|---|---|
| What must be empty | Every object, and every version and delete marker if versioning was ever enabled | Every object, version and delete marker - every bucket keeps every version |
| Access key scope | Any identity with s3:DeleteBucket on the bucket | A key for all buckets holding Delete buckets |
| Bucket in another region | 301 redirect with x-amz-bucket-region | 404 NoSuchBucket. The bucket's own regional endpoint is the one that deletes it. |
| A deletion still in progress | Not applicable | 503 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 bucket | Policies naming the bucket apply to a re-created bucket of the same name | A 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-owner | Checked against the bucket owner | Welcome, with nothing to check |
Examples
Deleting the empty bucket my-bucket:
- AWS CLI
- Python (boto3)
- JavaScript (AWS SDK v3)
aws s3api delete-bucket \
--bucket my-bucket \
--endpoint-url https://s3.eu-central-1.strg.com \
--region eu-central-1
import boto3
s3 = boto3.client(
"s3",
endpoint_url="https://s3.eu-central-1.strg.com",
region_name="eu-central-1",
)
s3.delete_bucket(Bucket="my-bucket")
import { DeleteBucketCommand, S3Client } from "@aws-sdk/client-s3";
const client = new S3Client({
endpoint: "https://s3.eu-central-1.strg.com",
region: "eu-central-1",
});
await client.send(new DeleteBucketCommand({ Bucket: "my-bucket" }));