I'm trying to find the size of S3 buckets. Is there any methods in Go SDK to accomplish this? This answer points to listing all objects & summarizing it using AWS cli, which looks to be too roundabout.
Asked
Active
Viewed 654 times
0
-
See [How can I get the size of an Amazon S3 bucket?](https://serverfault.com/questions/84815/how-can-i-get-the-size-of-an-amazon-s3-bucket) for more ways to get the size using command line tools. – Charlie Tumahai Jul 10 '20 at 05:42
1 Answers
4
CloudWatch publishes a metric called BucketSizeBytes
for each bucket with the size of all objects in the bucket. It is published once a day. There is also the NumberOfObjects
metric if that is of interest. For more information, see this documentation page.
The other way is to list the objects and summarize the size of each object, as you mentioned. This is the approach that you have to take if you are interested in a subset of the data (e.g. a prefix).
Another alternative may be to turn on inventory reporting and then process the reports in a suitable manner.

stefansundin
- 2,826
- 1
- 20
- 28
-
I wanted to get the entire bucket size, this seems to be the right way. Thanks! – Sandeep Jul 11 '20 at 11:33
-
what if want to get the size of entire bucket in my go code and do something based on the size ? Is there something in the official sdk ? I could not find anthing. – Amandeep kaur Jun 03 '21 at 06:05