AWS SDK V1 behavior with vpc endpoint

I am using AmazonS3Client object to check versioning status of a S3 bucket via VPC endpoint. Below is the code snippet:

AmazonS3Client s3Client = new AmazonS3Client(credentialsProvider);
s3Client.setSignerRegionOverride(region);
s3Client.setEndpoint(endPoint);
BucketVersioningConfiguration bvc = s3Client.getBucketVersioningConfiguration(S3Bucket);

Here, region is eu-west-1 and endpoint is bucket.vpce-abc-eu-west-1b.s3.eu-west-1.vpce.amazonaws.com. Endpoint is VPC endpoint (format is different than standard S3 endpoint).
AWS SDK version is 1.12.317.

Even though I am explicitly setting signer region to eu-west-1, the request is failing with error 400 AuthorizationHeaderMalformed with error message The authorization header is malformed; the region 'vpce' is wrong; expecting 'eu-west-1'.

For above request, host and authorization header is as below:

Host: S3Bucket.bucket.vpce-abc-eu-west-1b.s3.eu-west-1.vpce.amazonaws.com
Authorization: AWS4-HMAC-SHA256 Credential=access-key/20250515/vpce/s3/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-request;amz-sdk-retry;content-type;host;user-agent;x-amz-content-sha256;x-amz-date,Signature=signature"

I believe the issue is aws sdk is picking incorrect region 'vpce' for authorization from endpoint bucket.vpce-abc-eu-west-1b.s3.eu-west-1.vpce.amazonaws.com and ignoring setSignerRegionOverride as eu-west-1.

I am unable to understand why it is taking 'vpce' as region even though it should be 'eu-west-1'. Can some one explain why it is ignoring setSignerRegionOverride and how can I fix it ?

Read more here: Source link