Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create S3client without region in S3 V2 sdk #2229

Closed
rmunna opened this issue Jan 7, 2021 · 2 comments
Closed

Unable to create S3client without region in S3 V2 sdk #2229

rmunna opened this issue Jan 7, 2021 · 2 comments
Labels
feature-request A feature should be added or improved.

Comments

@rmunna
Copy link

rmunna commented Jan 7, 2021

The S3Client is failing with the following error when the client is created without the region specified. But where as in S3 sdk V1 it was possible to create the client without region.

Exception in thread "main" software.amazon.awssdk.core.exception.SdkClientException: Unable to load region from any of the providers in the chain software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain@2e1d27ba: [software.amazon.awssdk.regions.providers.SystemSettingsRegionProvider@7bb58ca3: Unable to load region from system settings. Region must be specified either via environment variable (AWS_REGION) or  system property (aws.region)., software.amazon.awssdk.regions.providers.AwsProfileRegionProvider@4d826d77: No region provided in profile: default, software.amazon.awssdk.regions.providers.InstanceProfileRegionProvider@7e9131d5: Unable to contact EC2 metadata service.]
	at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:98)
	at software.amazon.awssdk.regions.providers.AwsRegionProviderChain.getRegion(AwsRegionProviderChain.java:70)
	at software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder.regionFromDefaultProvider(AwsDefaultClientBuilder.java:202)
	at software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder.resolveRegion(AwsDefaultClientBuilder.java:184)
	at software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder.finalizeChildConfiguration(AwsDefaultClientBuilder.java:135)
	at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.syncClientConfiguration(SdkDefaultClientBuilder.java:157)
	at software.amazon.awssdk.services.s3.DefaultS3ClientBuilder.buildClient(DefaultS3ClientBuilder.java:27)
	at software.amazon.awssdk.services.s3.DefaultS3ClientBuilder.buildClient(DefaultS3ClientBuilder.java:22)
	at software.amazon.awssdk.core.client.builder.SdkDefaultClientBuilder.build(SdkDefaultClientBuilder.java:129)

Providing region to the the S3Client builder resolves the above error but we get the authorization header malformed error when we perform an operation on the bucket of different region.

Exception in thread "main" software.amazon.awssdk.services.s3.model.S3Exception: The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'us-east-2' (Service: S3, Status Code: 400, Request ID: DE3E42A889709617, Extended Request ID: Zw3FvxfFC2ap3+c69b1yJ6zCxdUVffO+gfBYXr5R3wHZKwnENH8soPo7jjLDped718OZkHOA8EY=)

v1

        AmazonS3 s3 = AmazonS3ClientBuilder.standard()
            .withCredentials(new AWSStaticCredentialsProvider(credentials))
            .withEndpointConfiguration(new EndpointConfiguration("https://s3.amazonaws.com",null))
            .build();

v2

S3Client.builder().credentialsProvider(StaticCredentialsProvider.create(credentials))
        .endpointOverride(URI.create("https://s3.amazonaws.com")).httpClient(sdkHttpClient)
        .build();

I am looking for a solution to create the S3Client without region as the customer doesn't provide the bucket region to us.

Your Environment

  • AWS Java SDK version used: 2.5.15
  • JDK version used: 11
  • Operating System and version: Windows 10
@rmunna rmunna added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 7, 2021
@debora-ito debora-ito added feature-request A feature should be added or improved. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 7, 2021
@debora-ito
Copy link
Member

This is not supported in v2 yet, we are tracking the feature request in #52.

@github-actions
Copy link

github-actions bot commented Jan 7, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

2 participants