def get_bucket_region(**kwargs):
# Some s3 buckets do not allow viewing of details. We do not want to
# throw an error in this case because we still want to see that the
# bucket exists
try:
result = get_bucket_location(**kwargs)
location = result['LocationConstraint']
except ClientError as e:
if 'AccessDenied' not in str(e):
raise e
return None
if not location:
return 'us-east-1'
return S3_REGION_MAPPING.get(location, location)
评论列表
文章目录