I want to calculate size of every s3 buckets and generate result like this
Bucket_name total size
('bucket_A ', 0)
('Bucket_B', 51090)
This is what I try so far:
import boto3
total_size = 0
s3=boto3.resource('s3')
for mybucket in s3.buckets.all():
mybucket_size=sum([object.size for object in boto3.resource('s3').Bucket(mybucket.name).objects.all()])
print (mybucket.name, mybucket_size)