I tried to find/get s3 bucket information using javascript/nodejs aws-sdk, but I didnt find such apis. How to get s3 bucket size / information via aws-sdk (javascript or node) api.
I tried to find/get s3 bucket information using javascript/nodejs aws-sdk, but I didnt find such apis. How to get s3 bucket size / information via aws-sdk (javascript or node) api.
Share Improve this question asked Oct 14, 2016 at 11:32 sk16sk16 531 silver badge5 bronze badges2 Answers
Reset to default 5Once a day the size of the bucket is reported to CloudWatch. The Metric is called BucketSizeBytes and you can supply the BucketName as a dimension and the StorageType (AllStorageTypes, StandardStorage, StandardIAStorage, ReducedRedundancyStorage).
You can use the JavaScript SDK to acceess the data in CloudWatch via the getMetricStatistics of the CloudWatch client. http://docs.aws.amazon./AWSJavaScriptSDK/latest/AWS/CloudWatch.html#getMetricStatistics-property
There is no API to get the bucket size other than enumerating all the objects.
One alternative approach would be to investigate the billing, but I think that will only yield inaccurate data as the billing handles a specific size over a specific time.