import boto3 s3 = boto3.resource('s3') def human_size(bytes, units=[' bytes','KB','MB','GB','TB', 'PB', 'EB']): return str(bytes) + units[0] if bytes < 1024 else human_size(bytes>>10, units[1:]) def get_bucket_size(balde): bucket = s3.Bucket(balde) total_size = 0 for k in bucket.objects.all(): total_size += k.size return total_size for bucket in s3.buckets.all(): bucket_size = human_size(get_bucket_size(bucket.name)) print('%s: %s' % (bucket.name, bucket_size))