Get the size of an AWS S3 Bucket


Slow version, fine if you have a reasonable number of files:

aws s3 ls --summarize --human-readable --recursive s3://YOUR-BUCKET-NAME/

Fast version, which uses CloudWatch stats:

 aws cloudwatch get-metric-statistics \
    --namespace AWS/S3 \
    --start-time $(date) \ 
    --end-time 2015-07-31T01:00:00 \
    --period 86400 \
    --statistics Average \
    --region YOUR-REGION \
    --metric-name BucketSizeBytes \
    --dimensions Name=BucketName,Value=YOUR-BUCKET-NAME Name=StorageType,Value=StandardStorage

The CloudWatch stats are also visible in the AWS S3 console, on the Metrics tab under each bucket

source

Date: 2025-02-20

Tags:  aws

Share: