Why in AWS CLI is required to specify region when using pre-signed URL?

Viewed 834

When I use the command aws s3 presign s3://my_bucket/my_image.png without specifying region I get an URL which redirects me to

<Message>The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.</Message>

Later, if I use aws s3 presign s3://my_bucket/my_image.png --region us-east-1 then it displays image correctly, but why is the --region us-east-1 required in order to work?

1 Answers

Because pre-signed S3 urls use sig4 signatures and this requires region. From docs:

The signing key is scoped to a specific Region and service, and it never expires.

Also, from CLI docs:

For sigv4 requests the region needs to be configured explicitly.

Related