Determine size of an S3 bucket or folder

Writing by on Wednesday, 16 of March , 2016 at 6:01 pm

Ensure that you have awscli installed as well as your keys setup in ~/.aws/credentials

To determine the size of an S3 Bucket or a folder, you can summarize the output as follows.

aws s3 ls –summarize –human-readable –recursive s3://mybucket/directory/

2015-03-05 19:57:33 71 Bytes directory/sub1/sub2/file.gz

Total Objects: 71
Total Size: 81.9 MiB

To determine the size of an S3 Bucket, you can also use s3api list-objects as shown below.

aws s3api list-objects –bucket mybucket –output json –query “[sum(Contents[].Size), length(Contents[])]”
[
351885203186,
4668
]

For more info refer to ServerFault

Leave a comment

Category: AWS

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.