Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the total size of my AWS S3 storage bucket or folder?

Does Amazon provide an easy way to see how much storage my S3 bucket or folder is using? This is so I can calculate my costs, etc.

like image 721
VernonFuller Avatar asked Aug 24 '15 21:08

VernonFuller


People also ask

What is the total size of S3 bucket?

Individual Amazon S3 objects can range in size from a minimum of 0 bytes to a maximum of 5 TB. The largest object that can be uploaded in a single PUT is 5 GB.

How do I find my S3 bucket details?

Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the Buckets list, choose the name of the bucket that you want to view the properties for. Choose Properties. On the Properties page, you can configure the following properties for the bucket.

How do you find out the largest S3 bucket you have?

Open the AWS S3 console and click on your bucket. Click on the Metrics tab. The Total bucket size graph in the Bucket Metrics section shows the total size of the objects in the bucket.


Video Answer


1 Answers

Two ways,

Using aws cli

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

If we omit / in the end, it will get all the folders starting with your folder name and give a total size of all.

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

Using boto3 api

import boto3  def get_folder_size(bucket, prefix):     total_size = 0     for obj in boto3.resource('s3').Bucket(bucket).objects.filter(Prefix=prefix):         total_size += obj.size     return total_size 
like image 89
Dipankar Avatar answered Oct 11 '22 01:10

Dipankar