Skip to content

Instantly share code, notes, and snippets.

@rafaftahsin
Last active July 5, 2023 10:00
Show Gist options
  • Save rafaftahsin/4c075a03ea83f9decbabe2741149a17b to your computer and use it in GitHub Desktop.
Save rafaftahsin/4c075a03ea83f9decbabe2741149a17b to your computer and use it in GitHub Desktop.
Size of Total Storage in CodeArtifact in a region
#!/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
@rafaftahsin
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment