Get the Size of a Folder in AWS S3 Bucket


Borislav Hadzhiev

Thu Sep 23 20212 min read

Get the Size of a Folder in S3 #

To get the size of a folder in an S3 bucket, you have to:

  1. Open the AWS S3 console and click on your bucket's name
  2. Optionally use the search input to filter by folder name
  3. Click on the checkbox next to your folder's name
  4. Click on the Actions button and select Calculate total size

calculate total size

Once you select the Calculate total size button you will be redirected to a screen where the total size of the folder is shown.

total size of folder

To get the size of a folder in an S3 bucket, using AWS CLI, run the s3 ls command, point to the folder's path and pass in the recursive, human-readable and summarize parameters.

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

aws cli total size of folder

The command's output shows:

  • the date the objects were created
  • individual file size of each object
  • the path of each object
  • the total number of objects in the s3 bucket
  • the total size of the objects in the bucket
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 folder contains 1,000,000 objects, you would make 1,000 requests and the List operation would cost you $0.005.

We've specified the following parameters in the call to the s3 ls command:

recursiveapplies the s3 ls command to all files under the specified directory
human-readabledisplays the file sizes in a human-readable format
summarizedisplays the number of objects and total size of the files

Further Reading #

Use the search field on my Home Page to filter through my more than 1,000 articles.