3 Ways to Get the Size of an Amazon S3 Bucket Quickly

3 Ways to Get the Size of an Amazon S3 Bucket Quickly

3 Ways to Get the Size of an Amazon S3 Bucket Quickly

Amazon S3 or Simple Storage Service is a highly available, infinitely scalable, secured and cost-effective object storage solution.

It’s one of the go-to services to store all kinds of data in AWS and allows you to store unlimited data.

Having said that, at times it becomes very very important to know the disk space that it is consuming. In other words, you should know how to get the size of an s3 bucket for management and governance purposes.

In this post, we will see 3 Ways to Get the Size of an Amazon S3 Bucket Quickly.

Don’t want to miss any posts from us? join us on our Facebook group, and follow us on Facebook, Twitter, LinkedIn, and Instagram. You can also subscribe to our newsletter below to not miss any updates from us.

Prerequisite

3 Ways to Get the Size of an Amazon S3 Bucket Quickly

There are many ways in which you can get the size of an s3 bucket. In this post, we’ll discuss 3 important ones that are easy and quick.

  1. Using Amazon S3 Console
  2. Using S3 Storage Lens Dashboard
  3. Using AWS CLI

I will be using one of my existing buckets to calculate its size. However, if you want to learn from the beginning, feel free to check my tutorial on How to Create an S3 Bucket in AWS Step By Step.

Way 1: Get the Size of an Amazon S3 Bucket using Amazon S3 Console

Login to AWS Management Console and navigate to Amazon S3 console. You can search s3 in the search bar and click on S3 to open the S3 console. Click on the bucket name for which you wish you find the size out.

For example, I want to find out the size of my demo-talk-with-anu bucket. So I clicked on the bucket name to go to the details screen.

Click on the “Matrics” tab

The total bucket size matrics show the size of your bucket as you can see in the below screenshot.

Ways to Get the Size of an Amazon S3 Bucket Quickly 1

If you hover over the blue dots, you will see the exact data like-

Ways to Get the Size of an Amazon S3 Bucket Quickly 5

My bucket is having 108.5 KB of data.

Important Note: This matrix gets updated every 24 hours. Therefore, if you have uploaded or removed new objects in your S3 bucket, the above data might be outdated.

Way 2: Get the Size of an Amazon S3 Bucket using Storage Lens Dashboard

Amazon S3 Storage Lens dashboard provides a unified view for S3 storage including usage and activity metrics for your bucket and account for detailed visibility.

Let’s see how can we get the bucket size using the s3 storage lens dashboard.

Once you are in S3 management console, on the top right corner, you will see a button View Storage Lens dashboard as shown in below screenshot.

Ways to Get the Size of an Amazon S3 Bucket Quickly 2

Click on View Storage Lens dashboard to open the dashboard. This is what the dashboard looks like-

Ways to Get the Size of an Amazon S3 Bucket Quickly 3

Click on the Bucket tab, and you will see the matric, date range and Top N buckets. You can change these values as per your need.

To get the size of the s3 bucket, we have selected the Total storage matric. The maximum date range doesn’t affect the total bucket size here.

Scroll down to the Buckets section-

Storage Lens Matrix

And, you will see the bucket size as highlighted in the above screenshot. Here is the bucket size for the bucket we were tracking.

For your info, S3 storage lens provides you with various free-of-charge metrics like-

  • Number of buckets in your account
  • Total number of objects in your account/bucket
  • Total storage in bytes in your account/bucket
  • The average number of objects etc.

Feel free to analyse the dashboard as per your requirement.

Way 3: Get the Size of an Amazon S3 Bucket using AWS CLI

Before you can use AWS CLI to get the size of your bucket, you need to have CLI installed and configured in your system. Or you can use a browser-based terminal named AWS CloudShell. Here is some help material on the same-

Once you are ready with the CLI, We’ll use s3 ls command to calculate the total size of the s3 bucket.

Here is the command to do so-

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

Explanation:

  • aws s3: Base command to work with s3
  • ls: command to list bucket objects(or folders depending on the path)
  • s3://bucket-name: URI of the bucket for which you want to get the size
  • recursive: ls command performed on all object including subfolders in the specified path
  • human-readable: Shows the size in human-readable format
  • summarize: Displays various information like the number of objects, total size

Feel free to check the details of the s3 ls command on official documentation.

Find the Size of demo-talk-with-anu bucket using CLI

I want to find the total size of my demo-talk-with-anu bucket. So here is the command for the same.

for us-

aws s3 ls s3://demo-talk-with-anu --recursive --human-readable --summarize

Let’s fire the command in CLI and see what happens.

Using CLI get total size of a bucket

As you can see total objects and total size is displayed.

Important Note: As we did ls in real-time here on the bucket, size is most accurate using this way. However, unlike other ways, this is not free. 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 10,000,000 objects, you would make 10,000 requests and the List operation would cost you $0.05. So be cautious while using this command on a large-size bucket.

Tips: Set up Budget in AWS Account to Avoid Billing Shocks

Conclusion

In this article, we learnt 3 ways to get the size of an Amazon S3 bucket quickly.

We started with finding the size of the bucket using the AWS console. Later we explored AWS S3 storage lens dashboard to fins out the total size. Finally, we saw the CLI way to calculate the total size.

We also saw that CLI is the most accurate as it gives the data in real-time. However, it’s not free, unlike the other two ways.

Well, that was my take on “3 Ways to Get the Size of an Amazon S3 Bucket Quickly“. Please feel free to share your feedback.

Enjoyed the content?

Subscribe to our newsletter below to get awesome AWS learning materials delivered straight to your inbox.

If you liked reading my post, you can motivate me by-

  • Adding a comment below on what you liked and what can be improved.
  • Follow us on FacebookTwitterLinkedInInstagram
  • Share this post with your friends and colleagues.

Suggested Read:

Leave a Reply

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