Last active
February 9, 2021 17:02
-
-
Save mjaromi/471ab9dceb87dab898a1e920ca6aa882 to your computer and use it in GitHub Desktop.
Show size 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
aws ecr describe-repositories | jq -r '.repositories[].repositoryName' | sort | while read repository; do | |
totalSizeOfUntagged=0 | |
while read imageSizeInBytes; do | |
totalSizeOfUntagged=$((totalSizeOfUntagged + imageSizeInBytes)) | |
done < <(aws ecr describe-images --repository-name ${repository} --filter tagStatus=UNTAGGED | jq -r '.imageDetails[].imageSizeInBytes') | |
if [[ ${totalSizeOfUntagged} -gt 0 ]]; then | |
echo -ne "${repository} - " | |
echo ${totalSizeOfUntagged} | awk '{ print $1/1024/1024 " MB" }' | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment