Created
February 5, 2019 09:28
-
-
Save fuxingloh/f062a954634bb7ebfb8fe7f659870c83 to your computer and use it in GitHub Desktop.
A simple bash script to remove all untagged ECS images.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws ecr describe-repositories --output text | awk '{print $5}' | while read line; do aws ecr list-images --repository-name $line --filter tagStatus=UNTAGGED --query 'imageIds[*]' --output text | while read imageId; do aws ecr batch-delete-image --repository-name $line --image-ids imageDigest=$imageId; done; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment