Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the title bar, choose your AWS Identity and Access Management (IAM) user name, and then choose My Billing Dashboard. In the navigation pane, choose AWS Cost & Usage Reports.
1 Answer. Show activity on this post. IsFolderEmpty (Virtual Folder: S3 does not have folder) : Request for Prefix="Folder" and delimiter=null - Check if listResponse's S3 Object Count is zero thats means Folder having prefix is empty or file(s) having prefix does not exist.
S3 storage provides the following key features: Buckets—data is stored in buckets. Each bucket can store an unlimited amount of unstructured data. Elastic scalability—S3 has no storage limit.
The command line tool gives a nice summary by running:
aws s3 ls s3://mybucket --recursive --human-readable --summarize
Yippe - an update to AWS CLI allows you to recursively ls through buckets...
aws s3 ls s3://<bucketname> --recursive | grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}'
To find out size of S3 bucket using AWS Console:
s3cmd can show you this by running s3cmd du
, optionally passing the bucket name as an argument.
The AWS CLI now supports the --query
parameter which takes a JMESPath expressions.
This means you can sum the size values given by list-objects
using sum(Contents[].Size)
and count like length(Contents[])
.
This can be be run using the official AWS CLI as below and was introduced in Feb 2014
aws s3api list-objects --bucket BUCKETNAME --output json --query "[sum(Contents[].Size), length(Contents[])]"
On linux box that have python
(with pip
installer), grep
and awk
, install AWS CLI (command line tools for EC2, S3 and many other services)
sudo pip install awscli
then create a .awssecret
file in your home folder with content as below (adjust key, secret and region as needed):
[default]
aws_access_key_id=<YOUR_KEY_HERE>
aws_secret_access_key=<YOUR_SECRET_KEY_HERE>
region=<AWS_REGION>
Make this file read-write to your user only:
sudo chmod 600 .awssecret
and export it to your environment
export AWS_CONFIG_FILE=/home/<your_name>/.awssecret
then run in the terminal (this is a single line command, separated by \
for easy reading here):
aws s3 ls s3://<bucket_name>/foo/bar | \
grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | \
awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}'
aws
part lists the bucket (or optionally a 'sub-folder')grep
part removes (using -v
) the lines that match the Regular Expression (using -E
). ^$
is for blank line, --
is for the separator lines in the output of aws s3 ls
awk
simply add to total
the 3rd colum of the resulting output (the size in KB) then display it at the endNOTE this command works for the current bucket or 'folder', not recursively
Cloud watch also allows you to create metrics for your S3 bucket. It shows you metrics by the size and object count. Services> Management Tools> Cloud watch. Pick the region where your S3 bucket is and the size and object count metrics would be among those available metrics.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With