Home > Software engineering >  How do I find the exact number of bytes of my AWS S3 bucket using AWS CLI?
How do I find the exact number of bytes of my AWS S3 bucket using AWS CLI?

Time:12-15

This thread: How do I find the total size of my AWS S3 storage bucket or folder? describes how to get the total filesize in an S3 bucket, but the result is not byte level accurate. I would need to know the exact number of bytes in the bucket.

This answer confirms my own observation, that the command

aws s3 ls --summarize --human-readable --recursive s3://bucket-name/

is not giving an output which is has byte level accuracy (tested it, and example output also confirms this). Similar advice is given here, here and here.

This thread: Check file size on S3 without downloading? describes a way which could be used, but provides no code.

The bucket is around half a terabyte with a few tens of thousands of files. It is just a one-off thing, I do not have to do this frequently.

CodePudding user response:

The easiest way is to use BucketSizeBytes metric in CloudWatch. For more granual size information you can request S3 inventory.

  • Related