Description
I have bucked in eu-west-1
, and want to resolve bucket location by api, but It fails when using non deprecated client builder.
DNS queries are changed, when for Frankfurt s3 you get something like this s3-w.eu-central-1.amazonaws.com
for Ireland datacenter it is only s3-3-w.amazonaws.com
...
So I wanted to implement api request that fetches location (using amazon cli I get expected responce)
{
"LocationConstraint": "eu-west-1"
}
Response, but when using Java Client's builder, region has to be defined, If you don't have region defined, you get this exception: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
, but when I define default us-east-1
for builder, I get exception The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'eu-west-1' (Service: Amazon S3; Status Code: 400; Error Code: AuthorizationHeaderMalformed; Request ID: XYZ)
Again, I could parse exception message, but that could also change.
For now one could use deprecated client new AmazonS3Client(getCredentialsProvider(bucket), getProxyConfiguration)
and it does still work.