Created
February 22, 2024 01:32
-
-
Save paul-civitas/242eea8d2e62730b526d042579e20cb9 to your computer and use it in GitHub Desktop.
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
bucket_list=$(aws s3api list-buckets --no-paginate | jq -r '.Buckets[].Name') | |
while read -r bucket ; do | |
echo -n "${bucket}," | |
aws cloudwatch get-metric-statistics --namespace AWS/S3 --start-time "$yesterday" --end-time "$current_time" --period 86400 --statistics Average --region us-east-1 --metric-name BucketSizeBytes --dimensions Name=BucketName,Value=$bucket Name=StorageType,Value=StandardStorage | jq '(.Datapoints[0].Average // 0)' | |
done <<< "$bucket_list" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment