The way to Get the Dimension of an Amazon S3 Bucket


AWS makes discovering the scale of an S3 bucket somewhat unintuitive and hidden within the menus. Right here’s the right way to to find the full dimension, graph it in CloudWatch, or fetch it programmatically from the command line.

The way to To find Bucket Dimension from the GUI

From the S3 Control Console, click on at the bucket you want to view. Below Control > Metrics > Garage, there’s a graph that presentations the full selection of bytes saved through the years.

Find size bucket through GUI

Moreover, you’ll view this metric in CloudWatch, along side the selection of gadgets saved. You’ll be able to use this so as to add the bucket dimension to a graph in a CloudWatch dashboard.


From the bucket assessment web page, you’ll additionally choose all pieces, and make a choice Movements > Get Overall Dimension. However, you probably have greater than one web page of things, you’ll’t choose the entirety, and it received’t be consultant of the bucket’s precise dimension.

You’ll be able to additionally view the bucket’s dimension from the Value Explorer, for the reason that billing division will, after all, have an excessively correct size of your utilization.

The way to Get Bucket Dimension from the CLI

You’ll be able to listing the scale of a bucket the usage of the AWS CLI, through passing the --summarize flag to s3 ls:

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

This may occasionally loop over every merchandise within the bucket, and print out the full selection of gadgets and overall dimension on the finish. In the event you’d like not to have your terminal flooded with each and every filename on your bucket, you’ll move the output to tail:

aws s3 ls s3://bucket --recursive --human-readable --summarize | tail -2

This may occasionally take a little time you probably have an excessively massive bucket. You should use (*5*)get-metric-data to fetch the scale from CloudWatch, however the syntax is clunky.

An more straightforward way is to put in s3cmd; It’s no longer part of the AWS CLI, so that you’ll need to manually set up it out of your distro’s bundle supervisor. For Debian-based programs like Ubuntu, that will be:

sudo apt-get set up s3cmd

As soon as s3cmd is put in, you’ll wish to run the next command to hyperlink it for your account together with your get entry to key (you’ll generate a brand new one from “My Safety Credentials”):

s3cmd --configure

As soon as it’s put in, you’ll get the scale of all your buckets briefly with:

s3cmd du -H 5.708148956298828M 2 gadgets s3://bucket/

This may occasionally show the scale of huge buckets a lot quicker than recursively summing record sizes will, because it fetches the real disk area used. Plus, it’s human readable if you happen to move the -H flag, so that you received’t have to damage out your calculator.