# Delete a bucket

Delete an empty bucket; its name becomes available to anyone again.

Only an empty bucket can be deleted: no objects, no older versions, no delete markers. Empty it
first (see [Empty a bucket](empty-a-bucket.md)). Replace _example-uploads_ with your bucket's name.

**Warning:**
Once deleted, the bucket's name is free for anyone on the platform to take.

## Prerequisites

- Permission for `s3:DeleteBucket` on the bucket.
- The bucket is empty, and no other bucket replicates into it.

## Delete the bucket

**Console**
1. Open **Object Storage**, then open the bucket.
2. In the **⋯** menu, choose **Delete bucket**.
3. Enter the bucket's name to confirm, then choose **Delete bucket**.

The console returns to the bucket list. From the bucket list, the row's **⋯** menu has the same
**Delete bucket**; there, enter the name and choose **Delete**. Without `s3:DeleteBucket`,
**Delete bucket** is unavailable in both menus; for a bucket a database or Kafka cluster
manages, it says the bucket is deleted together with it.

**CLI**
```sh
dcloud s3 buckets delete example-uploads
```

**API**
```http
DELETE /s3/api/buckets/example-uploads
```

**Terraform**
Remove the `dcloud_bucket` resource and apply. Terraform's delete is refused like any other while
the bucket holds objects.

## If the delete is refused

- 409 `example-uploads is not empty. Empty it first (the bucket's "Empty bucket" action, or delete-prefix with allVersions), then delete it.`
- 409 `example-uploads is a replication destination of …. Remove that replication first.`: remove
  the replication on the source bucket (see [Replicate a bucket](replicate-a-bucket.md)).
- 409 `“rds-…” belongs to database … and is deleted with it`: a database's backup bucket goes
  with the database.
- 409 `“…” holds the tiered storage of Kafka cluster … and is deleted with it`: a Kafka cluster's
  tiered-storage bucket goes with the cluster.
- 409 `example-uploads still lists … entries that storage cannot read or delete. This is a fault on our side, not something you can fix: we repair such buckets, and you can delete it once that is done.`
  See [Troubleshooting](troubleshooting.md#a-bucket-shows-entries-storage-cannot-read).
- 409 `Object storage still counts objects in example-uploads that were just deleted. Try again in a few minutes.`
- 503 `Object storage does not see example-uploads everywhere yet (it can take a minute after a bucket is created). Try again in a minute.`,
  with `Retry-After: 60`.
- 403 `Forbidden` without `s3:DeleteBucket` on the bucket.

## Related

- [Empty a bucket](empty-a-bucket.md)
- `s3.buckets.delete` · `dcloud s3 buckets delete` · `dcloud_bucket`
