Last active
November 2, 2016 10:06
-
-
Save haitaoyao/5770a2d9773d998fc94923a7b5cc5399 to your computer and use it in GitHub Desktop.
get the estimated storage size of AWS buckets without listing all the objects
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
bucket_name=$1 | |
[ -z "$bucket_name" ] && echo "usage: $0 bucket_name" && exit 1 | |
start_time=`date +'%FT%T' -d '-3 days'` | |
end_time=`date +'%FT%T'` | |
aws cloudwatch --region cn-north-1 \ | |
get-metric-statistics \ | |
--namespace AWS/S3 \ | |
--metric-name BucketSizeBytes \ | |
--start-time $start_time \ | |
--end-time $end_time \ | |
--period 86400 \ | |
--statistics Average \ | |
--dimensions Name=BucketName,Value=$bucket_name\ | |
Name=StorageType,Value=StandardStorage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment