Last active
July 5, 2023 10:00
-
-
Save rafaftahsin/4c075a03ea83f9decbabe2741149a17b to your computer and use it in GitHub Desktop.
Size of Total Storage in CodeArtifact in a region
This file contains hidden or 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
#!/bin/bash | |
export AWS_PROFILE=profile | |
domains=$(aws codeartifact list-domains | jq -r ".domains[].name") | |
total_artifactory_size=0 | |
for d in $domains; do | |
repos=$(aws codeartifact list-repositories-in-domain --domain $d | jq -r ".repositories[].name") | |
for r in $repos; do | |
packages=$(aws codeartifact list-packages --domain $d --repository $r | jq -r ".packages[].package") | |
for p in $packages; do | |
packageversions=$(aws codeartifact list-package-versions --package $p --domain $d --repository $r --format pypi | jq -r ".versions[].version") | |
for pv in $packageversions; do | |
sizes=$(aws codeartifact list-package-version-assets --domain $d --repo $r --format pypi --package $p --package-version $pv | jq -r ".assets[].size") | |
echo $d" "$p" "$r" "$pv" "$sizes >>size.tb | |
total=0 | |
for size in $sizes; do | |
sum=$(($total + $size)) | |
done | |
echo "Package Size: $sum" >>size.tb | |
total_artifactory_size=$((total_artifactory_size + $sum)) | |
done | |
done | |
done | |
done | |
echo "Total Artifactory Size: $total_artifactory_size" | |
# aws codeartifact list-package-version-assets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried to find a better way, waiting for an answer. - https://stackoverflow.com/questions/76598280/better-way-to-know-total-storage-consumed-by-a-codeartifact-repository