# Delete a repository

Delete a repository with every image, tag and scan in it.

Replace repository-id with the repository's id.

**Warning:**
Deleting a repository cannot be undone. Its images are not restorable, and a pull of any of its
tags fails from then on, including from a running deployment.

## Prerequisites

- Permission for `ecr:DeleteRepository` on the repository.
- In the console, also `ecr:DescribeRepositories` on it; without it the repository's page answers 404.

## Delete it

**Console**
1. Open **Image repositories**, then open the repository.
2. Open the **Danger zone** tab. (**Delete repository** in the page's **⋯** menu opens it too.)
3. Under **Delete this repository**, choose **Delete repository**.
4. Type the repository's name, then choose **Delete repository**.

The console returns to the repository list. Without the permission, the tab says "Your policies do
not grant ecr:DeleteRepository on this repository; ask an administrator." and the button is off.

**CLI**
```sh
dcloud ecr repositories delete repository-id
```

**API**
```http
DELETE /ecr/api/repositories/repository-id
```

**Terraform**
Remove the `dcloud_ecr_repository` resource from your configuration and apply.

## Result

`200` with the deleted repository. Its images, tags and scans are gone. Its layers are no longer
used by it; layer cleanup deletes the ones no other repository holds (see
[Storage and cleanup](storage-and-cleanup.md)). A `404` `Not found` answers an unknown id.

## Related

- [Delete a tag or an image](delete-a-tag-or-image.md)
- `ecr.repositories.delete` · `dcloud ecr repositories delete` · `dcloud_ecr_repository`
