How to Get the Size of an Amazon S3 Bucket

AWS makes discovering the measurement of an S3 bucket pretty unintuitive and hidden in the menus. Here’s how to discover the complete measurement, graph it in CloudWatch, or fetch it programmatically from the command line.

How to Find Bucket Size from the GUI

From the S3 Management Console, click on on the bucket you would like to view. Under Management > Metrics > Storage, there’s a graph that exhibits the complete quantity of bytes saved over time.

Find size bucket through GUI

Additionally, you may view this metric in CloudWatch, together with the quantity of objects saved. You can use this to add the bucket measurement to a graph in a CloudWatch dashboard.

View bucket size metric in CloudWatch.

From the bucket overview web page, you too can choose all objects, and select Actions > Get Total Size. But, if in case you have multiple web page of objects, you may’t choose all the things, and it gained’t be consultant of the bucket’s precise measurement.

You may also view the bucket’s measurement from the Cost Explorer, as a result of the billing division will, of course, have a really correct measurement of your utilization.

How to Get Bucket Size from the CLI

You can listing the measurement of a bucket utilizing the AWS CLI, by passing the --summarize flag to s3 ls:

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

This will loop over every merchandise in the bucket, and print out the complete quantity of objects and complete measurement at the finish. If you’d like to not have your terminal flooded with each filename in your bucket, you may move the output to tail:

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

This will take some time if in case you have a really giant bucket. You might use get-metric-data to fetch the measurement from CloudWatch, however the syntax is clunky.

An simpler methodology is to set up s3cmd; It’s not a component of the AWS CLI, so that you’ll have to manually set up it out of your distro’s bundle supervisor. For Debian-based techniques like Ubuntu, that might be:

sudo apt-get set up s3cmd

Once s3cmd is put in, you’ll want to run the following command to hyperlink it to your account along with your entry key (you may generate a brand new one from “My Security Credentials”):

s3cmd --configure

Once it’s put in, you may get the measurement of all of your buckets shortly with:

s3cmd du -H

5.708148956298828M 2 objects s3://bucket/

This will show the measurement of giant buckets a lot sooner than recursively summing file sizes will, because it fetches the precise disk area used. Plus, it’s human readable if you happen to move the -H flag, so that you gained’t have to escape your calculator.

Source link

This Web site is affiliated with Amazon associates, Clickbank, JVZoo, Sovrn //Commerce, Warrior Plus etc.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *