Skip to content

Instantly share code, notes, and snippets.

@fuxingloh
Created February 5, 2019 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fuxingloh/f062a954634bb7ebfb8fe7f659870c83 to your computer and use it in GitHub Desktop.
Save fuxingloh/f062a954634bb7ebfb8fe7f659870c83 to your computer and use it in GitHub Desktop.
A simple bash script to remove all untagged ECS images.
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