Wed Sep 22 2021·2 min read
Photo by George Gvasalia
In order to get the size of an S3 Bucket, you have to:
Bucket Metricssection, the
Total bucket sizegraph 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 in the
1,000requests in the
us-east-1region. For example, if your bucket contains
1,000,000objects, the List operation would cost you
1,000 * $0.005 = $5
aws s3 ls s3://YOUR_BUCKET --recursive --human-readable --summarize
The command's output shows:
The parameters we've 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.
I'll send you 1 email a week with links to all of the articles I've written that week