How to Get the Size of an AWS S3 Bucket

avatar

Borislav Hadzhiev

Wed Sep 22 20212 min read

Get the Size on an S3 Bucket #

In order to get the size of an S3 Bucket, you have to:

  1. Open the AWS S3 console and click on your bucket
  2. Click on the Metrics Tab
  3. In the Bucket Metrics section, the Total bucket size graph shows the total size of the objects in the bucket

total size of bucket

You can hover over the line in the graph to look at the size movements of your bucket. These metrics are also available in CloudWatch.

The next graph on the page shows the total number of objects in the S3 bucket.

Note that this metric is updated daily, so if you have performed PUT / DELETE actions on the bucket in the past 24 hours, it might not be up to date. Hover over the graph line to see the last time it got updated.

To get the size of an S3 Bucket using the AWS CLI, run the s3 ls command, passing in the recursive, human-readable and summarize parameters.

S3 List operations cost about $0.005 per 1,000 requests in the us-east-1 region. For example, if your bucket contains 1,000,000 objects, the List operation would cost you 1,000 * $0.005 = $5
shell
aws s3 ls s3://YOUR_BUCKET --recursive --human-readable --summarize

get bucket size aws cli

The command's output shows:

  • the date the objects were created
  • their individual file sizes
  • their path
  • the total number of objects in the s3 bucket
  • the total size of the objects in the bucket

The parameters we've passed to the s3 ls command are:

NameDescription
recursiveperforms the command on all files under the set prefix
human-readabledisplays the file sizes in human readable format
summarizedisplays the total number of objects and their total size

To get the size of the objects in a specific folder of an S3 bucket, call the s3 ls command with the complete S3 URI pointing to the folder.

shell
aws s3 ls s3://YOUR_BUCKET/YOUR_FOLDER/ --recursive --human-readable --summarize

get folder size

To get more S3 bucket metrics, navigate to the S3 console and click on the View Storage Lens dashboard button.

storage lens dashboard

Then click on the Bucket tab:

bucket tab

S3 Storage lens provides us with free of charge metrics, including:

  • number of buckets
  • total objects in your account / specific bucket
  • total storage in your account / specific bucket
  • average number of objects
  • many others

The metrics get collected daily and are retained for a period of 14 days.

storage lens metrics

Further Reading #

Join my newsletter

I'll send you 1 email a week with links to all of the articles I've written that week

Buy Me A Coffee