Created
October 13, 2020 21:25
-
-
Save mjaromi/198e46c282d347bad0bc215c9e001742 to your computer and use it in GitHub Desktop.
Show number of UNTAGGED images per ECR repository
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
totalNumberOfUntagged=0 | |
while read repository; do | |
numberOfUntagged=$(aws ecr list-images --repository-name ${repository} --filter tagStatus=UNTAGGED --query 'imageIds[*]' | jq -r '.[].imageDigest' | wc -l) | |
if [[ ${numberOfUntagged} -gt 0 ]]; then | |
echo "${repository} - ${numberOfUntagged}" | |
totalNumberOfUntagged=$((totalNumberOfUntagged + numberOfUntagged)) | |
fi | |
done < <(aws ecr describe-repositories | jq -r '.repositories[].repositoryName' | sort) | |
echo ${totalNumberOfUntagged} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment