I am looking at my AWS S3 Bucket and I can see there are lots of files in it, but I am not sure, how much space these files are consuming on Amazon S3 bucket so, how can I know AWS S3 Bucket size using AWS console or AWS S3 Cmd easily and quickly.
Here are some methods to get AWS S3 Bucket size:
Using AWS CLI
aws s3api list-objects --bucket BUCKETNAME --output json --query "[sum(Contents[].Size), length(Contents[])]"
Using AWS Console
Using CLI, another method
aws s3 ls --summarize --human-readable --recursive s3://bucket-name/
Using AWS Cloudwatch command, much faster than other CLI commands as it doesn't calculate size of each file
aws cloudwatch get-metric-statistics --namespace AWS/S3 --start-time 2022-07-15T10:00:00 --end-time 2022-07-31T01:00:00 --period 86400 --statistics Average --region eu-west-1 --metric-name BucketSizeBytes --dimensions Name=BucketName,Value=example.com Name=StorageType,Value=StandardStorage
You will have to specify both StorageType and BucketName in the dimensions argument otherwise you will get no results.
Also you need to change is the --start-date, --end-time, and Value.
Using Cloudwatch GUI
Using S4CMD
s4cmd du s3://bucket-name
This approach is also faster than above CLI commands.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly