Borislav Hadzhiev
Wed Sep 22 2021·3 min read
Photo by George Gvasalia
In order to get the size of an S3 Bucket, you have to:
Metrics
TabBucket Metrics
section, the Total bucket size
graph shows the
total size of the objects in the bucketYou 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 recursive
, human-readable
and summarize
parameters.
$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 1,000,000
objects, you would make 1,000
requests and the List operation would cost you $0.005
.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:
Name | Description |
---|---|
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 Bucket
tab:
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.