Boto3 get only S3 buckets of specific region
问题 The following code sadly lists all buckets of all regions and not only from "eu-west-1" as specified. How can I change that? import boto3 s3 = boto3.client("s3", region_name="eu-west-1") for bucket in s3.list_buckets()["Buckets"]: bucket_name = bucket["Name"] print(bucket["Name"]) 回答1: s3 = boto3.client("s3", region_name="eu-west-1") connects to S3 API endpoint in eu-west-1 . It doesn't limit the listing to eu-west-1 buckets. One solution is to query the bucket location and filter. s3 = boto3