如何确定公共 AWS S3 存储桶的区域?

Nic*_*ofi 17 amazon-s3 amazon-web-services

我知道我可以通过执行以下操作来确定我拥有的 AWS S3 存储桶的区域:

aws s3api get-bucket-location --bucket <my-bucket>
Run Code Online (Sandbox Code Playgroud)

但是我如何确定公共访问存储桶的区域(显然我不拥有该区域)?

如果我尝试访问 AWS 开放数据存储桶之一(例如 noaa-goes16):

$ aws s3api get-bucket-location --bucket noaa-goes16
Run Code Online (Sandbox Code Playgroud)

我得到:

An error occurred (AccessDenied) when calling the GetBucketLocation operation: Access Denied
Run Code Online (Sandbox Code Playgroud)

Ric*_*ell 30

是的,你可能认为这会更容易弄清楚,但这是我使用的方法:

$ curl -sI https://noaa-goes16.s3.amazonaws.com | grep bucket-region
Run Code Online (Sandbox Code Playgroud)

返回:

x-amz-bucket-region: us-east-1
Run Code Online (Sandbox Code Playgroud)


Chr*_*ams 7

从存储桶返回的任何对象都将使用x-amz-bucket-region包含存储桶区域的标头进行响应。

此外,通过curl --head $BUCKET_NAME.s3.amazonaws.com对您的存储桶运行 head 命令,您可以看到上面的标头来识别您的存储桶所在的区域。