【发布时间】:2021-05-03 22:47:55
【问题描述】:
我刚刚使用 AWS CLI 创建了一个存储桶:
aws s3 mb s3://new-bucket-created
然后当使用 boto3 列出我的 S3 帐户中的所有存储桶时:
s3 = boto3.client('s3')
response = s3.list_buckets()
buckets = {}
for bucket in response['Buckets']:
bucket_name = bucket["Name"]
bucket_region = s3.get_bucket_location(Bucket=bucket_name)['LocationConstraint']
buckets.update({bucket_name:bucket_region})
for bucket, region in buckets.items():
print("{}, {}".format(bucket, region))
输出显示区域指定为 sa-east-1 的所有旧存储桶,但新存储桶为无:
输出
older-bucket, sa-east-1
another-older-bucket, sa-east-1
yet-another-older-bucket, sa-east-1
new-bucket-created, None
我可以在新创建的存储桶中写入,但为什么我看不到它的区域?确定有地方,有什么想法吗?
【问题讨论】:
-
您是否阅读过有关
s3.get_bucket_location何时可能返回 None 的文档?
标签: python amazon-web-services boto3