How to get size of an Amazon S3 bucket?


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.


Asked by:- jaya
1
: 1792 At:- 10/1/2022 2:36:25 PM
AWS get size of an s3 bucket







1 Answers
profileImage Answered by:- vikas_jk

Here are some methods to get AWS S3 Bucket size:

Method 1:

Using AWS CLI

aws s3api list-objects --bucket BUCKETNAME --output json --query "[sum(Contents[].Size), length(Contents[])]"

Method 2:

Using AWS Console

  • You can also open AWS Console in browser
  • search for "S3", open Amazon S3 
  • then select "Buckets"
  • then select the bucket for which you want to check size
  • then click on "Metrics" tab to check total size consumed by that Amazon S3 Bucket
    total-aws-s3-bucket-size

Method 3:

Using CLI, another method

aws s3 ls --summarize --human-readable --recursive s3://bucket-name/

Method 4:

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.

Method 5:

Using Cloudwatch GUI

  • Open Amazon Web Server Console
  • Search for 'Cloudwatch' and Click on first result
  • From left menu, select "Metrics" -> "All Metrics"
  • Then select on Bucket for which you want to check Size.

Method 6:

Using S4CMD

s4cmd du s3://bucket-name

This approach is also faster than above CLI commands.

1
At:- 10/1/2022 2:53:36 PM
Excellent detailed answer with all the methods to check AWS s3 bucket size, thanks. 0
By : jaya - at :- 10/1/2022 3:01:02 PM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use