Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I determine the region for a public AWS S3 bucket?

I know I can determine the region for AWS S3 buckets I own by doing:

aws s3api get-bucket-location --bucket <my-bucket>

but how can I determine the region for a public access bucket (which clearly I do not own)?

If I try to access one of the AWS Open Data buckets like noaa-goes16:

$ aws s3api get-bucket-location --bucket noaa-goes16

I get:

An error occurred (AccessDenied) when calling the GetBucketLocation operation: Access Denied
like image 868
Nicokofi Avatar asked Jul 20 '20 13:07

Nicokofi


People also ask

Does S3 buckets have region?

Amazon S3 creates buckets in a Region that you specify. To optimize latency, minimize costs, or address regulatory requirements, choose any AWS Region that is geographically close to you.

Is S3 Bucket regional or global?

While the name space for buckets is global, S3 (like most of the other AWS services) runs in each AWS region (see the AWS Global Infrastructure page for more information).

What is default region for S3 bucket?

If you don't specify a Region when you create a client or a bucket, Amazon S3 uses the default Region US East (N. Virginia). To create a client to access a dual-stack endpoint, you must specify an AWS Region.


2 Answers

Yeah, you would think this would be easier to figure out, but here's the method I use:

$ curl -sI https://noaa-goes16.s3.amazonaws.com | grep bucket-region

which returns:

x-amz-bucket-region: us-east-1
like image 70
Rich Signell Avatar answered Oct 17 '22 17:10

Rich Signell


Any objects returned from the bucket will respond with a x-amz-bucket-region header which contains the buckets region.

In addition by running a head command curl --head $BUCKET_NAME.s3.amazonaws.com against your bucket you can see the above header to identify the region your bucket is in.

like image 24
Chris Williams Avatar answered Oct 17 '22 16:10

Chris Williams