Skip to content

Instantly share code, notes, and snippets.

@mjaromi
Created October 13, 2020 21:25
Show Gist options
  • Save mjaromi/198e46c282d347bad0bc215c9e001742 to your computer and use it in GitHub Desktop.
Save mjaromi/198e46c282d347bad0bc215c9e001742 to your computer and use it in GitHub Desktop.
Show number of UNTAGGED images per ECR repository
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