Deletes old images from ecr
This clean up a specific repository as well as all repos within an aws account.
- Retrieve repo from ecr
- Get repo images
- Add all images without tags to deletion
- Sort the remaining images in alphanumeric order
- Add n oldest images to deletion
- Delete images from the repository
go get github.com/WeltN24/ecr-cleaner
aws.region = eu-central-1
dry-run = false
amount-to-keep = 100
clean up all repos
ecr-cleaner -aws.region eu-west-1
clean up my-awesome-repo
ecr-cleaner -aws.region eu-west-1 -repository my-awesome-repo
go for a dry run
ecr-cleaner -aws.region eu-west-1 -repository my-awesome-repo -dry-run true
leave n images in repo
ecr-cleaner -aws.region eu-west-1 -repository my-awesome-repo -amount-to-keep 5