User Tools

Site Tools


aws

AWS Cli Tips

Get the total size of an S3 Bucket (or path)

aws s3 ls --summarize --human-readable --recursive s3://BUCKETNAME/PATH
or
aws s3 ls s3://BUCKETNAME/PATH --recursive | awk '{total+=$3} END{print "total =",total/1024/1024," MB"}'

Get the total size of an S3 Bucket (using CloudWatch, for high volumes)

aws cloudwatch get-metric-statistics --namespace AWS/S3 \
  --start-time 2018-02-05T00:00:00 --end-time 2018-02-06T00:00:00 \
  --period 86400 --statistics Average --region eu-west-1 --metric-name BucketSizeBytes \
  --dimensions Name=BucketName,Value=BUCKETNAME Name=StorageType,Value=StandardStorage \
  | jq -r '.Datapoints[0].Average' \
  | awk '{total+=$0} END{print "total =",int(total/1024/1024)," MB"}'

aws.txt · Last modified: 2018/02/06 15:46 by jdx