Last updated: Jul 25, 2022
Photo from Unsplash
To get the size of an AWS S3 Bucket:
Total bucket sizegraph in the
Bucket Metricssection shows the total size of the objects in the 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.
To get the size of an S3 Bucket using the AWS CLI, run the
s3 ls command,
passing it the
1,000requests, where each request returns a maximum of
us-east-1region). For example, if your bucket contains
1,000,000objects, you would make
1,000requests and the List operation would cost you
aws s3 ls s3://YOUR_BUCKET --recursive --human-readable --summarize
The command's output shows:
The parameters we passed to the s3 ls command are:
|recursive||performs the command on all files under the set prefix|
|human-readable||displays the file sizes in human readable format|
|summarize||displays 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
To get more S3 bucket metrics, navigate to the S3 console and click on the
View Storage Lens dashboard button.
Then click on the
S3 Storage lens provides us with free of charge metrics, including:
The metrics get collected daily and are retained for a period of 14 days.