l3_08 l3_08 - 1 year ago 109
Python Question

Get the names and count of all buckets in AWS S3

I'm new to Boto3 and AWS API, and I want to get the list of buckets' names and the count of the available buckets in S3.

Any help is appreciated.

Answer Source

To get all buckets in your account:

import boto3

s3 = boto3.resource('s3')
bucket_list = [bucket.name for bucket in s3.buckets.all()]
print len(bucket_list)
print bucket_list
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download