Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sstarcher/ecr-cleaner

Opinionated tool to clean out ECR images
https://github.com/sstarcher/ecr-cleaner

Last synced: 19 days ago
JSON representation

Opinionated tool to clean out ECR images

Awesome Lists containing this project

README

        

# ECR Cleaner
This tool helps you clean up your ECR repository. ECR is limited in how you can remove images by either a amount of elapsed time or via an expression matching the name. Due to the limitations in this combination this tool exists.

### Purging
* The image must be over 90 days old unless `--days` is set.
* Image tags that are [SemVer](https://semver.org/) compatible are kept by default set `--no-semver` to remove SemVer tags. If the tag starts with a r or v those characters will be stripped and the remainder of the name will be tested for SemVer compatiability.
* `--dry-run` allows you to run the command to see what the results would be.
* By default it will skip any repo that would have all images removed set `--force` to remove them anyways

## Helm Install

Using helm 3

```
$ helm repo add sstarcher https://shanestarcher.com/helm-charts/
$ helm install ecr-cleaner sstarcher/ecr-cleaner
```

If using kube2iam you will want to specify podAnnotations
```yaml
podAnnotations:
iam.amazonaws.com/role: IAM_ROLE
```

By default dry-run is turned on and nothing will be deleted. Set the following to disable dry-run.
```yaml
config:
dryRun: false
```

### AWS IAM Policy

The following permissions will be needed by ecr-cleaner to function.

```
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ecr-cleaner",
"Effect": "Allow",
"Action": [
"ecr:BatchDeleteImage",
"ecr:BatchGetImage",
"ecr:DescribeImages",
"ecr:ListImages",
"ecr:DescribeRepositories"
]
}
]
}
```

## Automated Docker Builds

This is handled by docker hub's automated [build process](https://hub.docker.com/repository/docker/sstarcher/ecr-cleaner/).