How to Get the Size of an AWS S3 Bucket

Borislav Hadzhiev

Last updated: Feb 26, 2024
3 min


# Get the Size on an S3 Bucket

To get the size of an AWS S3 Bucket:

  1. Open the AWS S3 console and click on your bucket.
  2. Click on the Metrics tab.
  3. The Total bucket size graph in the Bucket Metrics section 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. If you have performed PUT or DELETE actions on the bucket in the past 24 hours, it might not be up to date. Hover over the graph line to see when it was last updated.

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

S3 List operations cost about $0.005 per 1,000 requests, where each request returns a maximum of 1,000 objects (us-east-1 region). For example, if your bucket contains 1,000,000 objects, you would make 1,000 requests and the List operation would cost you $0.005.
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 passed to the s3 ls command are:

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.

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.
  • the average number of objects.
  • many others

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

storage lens metrics

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.