AWS CLI – S3, why do I need to specify a region

amazon s3amazon-web-services

So my bucket Alpha is in a region called REGION1.

My bucket Beta is in a different region, let's call it REGION2.

I go into my EC2 instance, and use this command:

aws s3 cp s3://Alpha/meh.txt ./meh.txt

It works! So far so good. It works perfectly.

But, when I do this command:
aws s3 cp s3://Beta/qwe.txt ./qwe.txt

I get the following error message:

fatal error: An error occurred (400) when calling the HeadObject operation: Bad Request

The error above can only be fixed if I specify the region flag. Why is that?
Because I thought bucket names are unique regardless of region, so why should I need to specify a region?

Is there a way to stop this from happening without specifying a region? Maybe a special policy or something?

Thank you.

Best Answer

Only AWS knows the answer to this. AWS could remove this requirement, but I guess they want you to be explicit.

It would be simple enough to do automatically. When the client gets a request to a bucket a central lookup service could determine the bucket region and send the request there. That however creates a single point of failure. You could work around that by running the lookup service in every region, and having all the endpoints in the client, but that's more code, more configuration, more services to run, more services taking CPU.

If they didn't want to run a lookup service then the requests would have to go via a central point, proxied to your region. That takes CPU and bandwidth.

It's probably easier and more efficient to specify the region than the other options.