How to get a list of all S3 Buckets in a region using boto3

import boto3

# Create S3 client
s3 = boto3.client(
  's3',
  # Replace with your region like us-east-1
  region_name='us-west-2'
)

# Call S3 to list current buckets
response = s3.list_buckets()

# Get a list of all bucket names from the response
buckets = [bucket['Name'] for bucket in response['Buckets']]
print(buckets)
15 lines of code, 323 characters

Similar AWS code snippets using python

Finally, a good search for AWS Console

Was that in us-east-1? Or us-west-2? No need to remember. Just type the name of the resource and CloudTempo will find it.

Feature