Create S3 Client with endpointOverride and no Region
See original GitHub issueDescribe the Feature
I would like to be able to create a S3 client without the region if I provide the endpoint configuration.
With the V1 SDK I can create and use a client without a region when I provide the endpoint configuration.
EndpointConfiguration epc = new EndpointConfiguration("http://" + overrideHost + ":" + httpsPort, null);
AmazonS3 s3Client = AmazonS3Client.builder().withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(ACCESS_KEY_ID, SECRET_KEY)))
.withEndpointConfiguration(epc).withPathStyleAccessEnabled(true).build();
With the V2 SDK I get an exception:
S3ClientBuilder builder = S3Client.builder();
builder.credentialsProvider(
StaticCredentialsProvider.create(AwsBasicCredentials.create(ACCESS_KEY_ID, SECRET_KEY)));
builder.endpointOverride(URI.create("http://" + overrideHost + ":" + httpsPort));
S3Configuration confBuilder = S3Configuration.builder().pathStyleAccessEnabled(true).build();
builder
.serviceConfiguration(confBuilder)
.httpClient(
UrlConnectionHttpClient.builder().build());
S3Client client = builder.build();
[ERROR] Unable to load region from any of the providers in the chain software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain@29caf222: [software.amazon.awssdk.regions.providers.SystemSettingsRegionProvider@5fcacc0: 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@5b6813df: No region provided in profile: default, software.amazon.awssdk.regions.providers.InstanceProfileRegionProvider@1d572e62: Unable to contact EC2 metadata service.]
Is your Feature Request related to a problem?
Trying to set configuration to leverage different S3 compatible data sources using this SDK.
Proposed Solution
Describe alternatives you’ve considered
Use the V1 SDK, but would like to stay on the latest. Also considered leaving a default region in there, but that makes the code more confusing as the value is meaningless when the endpoint is provided.
Additional Context
Have the requirement to be able to switch between S3 endpoints based on configuration. With the requirement of a region I will either be plugging in a dummy value that will make the code more confusing, or using the older SDK.
- I may be able to implement this feature request
Your Environment
- AWS Java SDK version used: 2.13.45 and 1.11.860
- JDK version used: 1.8
- Operating System and version: Windows and Linux
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:10 (8 by maintainers)
I think it’s a good idea to support non-aws s3 providers, because S3 is a protocol and there are already multiple industry implementations, thus everybody wins if an SDK supports many implementations of the standard. Likewise, it would be awkward if a non-aws client library didn’t work with specifically AWS S3.
Even though using a non-AWS endpoint doesn’t seem to be officially supported by the v2 SDK based on the conversation above, we’ve been able to use it up to this point by configuring a dummy region. With a recent change in 2.17.79, this is no longer possible either as using a non-AWS region name results in a
NullPointerException
.Should we update the README of this project to explicitly indicate this SDK is only usable with AWS S3?