Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 452
l3_08 Avatar asked Oct 24 '25 12:10

l3_08


1 Answers

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
like image 179
helloV Avatar answered Oct 26 '25 01:10

helloV



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!