使用“LocationConstraint”属性来获得存储桶位置信息。示例如下:
import boto3
s3 = boto3.client('s3')
response = s3.create_bucket(
ACL='private',
Bucket='example-bucket',
CreateBucketConfiguration={'LocationConstraint': 'us-west-2'}
)
在这个示例中,使用“CreateBucketConfiguration”参数来指定存储桶位置信息,其中“LocationConstraint”属性用于指定存储桶所在的AWS区域。使用这种方法,可以在创建存储桶时获取存储桶的位置信息。