File tree 2 files changed +12
-4
lines changed
plugins/repository-s3/src/main/java/org/opensearch/repositories/s3
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ class S3AsyncService implements Closeable {
60
60
61
61
private static final String STS_ENDPOINT_OVERRIDE_SYSTEM_PROPERTY = "aws.stsEndpointOverride" ;
62
62
63
- private static final String DEFAULT_S3_ENDPOINT = "s3.amazonaws.com" ;
63
+ private static final String GLOBAL_S3_ENDPOINT = "s3.amazonaws.com" ;
64
64
65
65
private volatile Map <S3ClientSettings , AmazonAsyncS3Reference > clientsCache = emptyMap ();
66
66
@@ -174,7 +174,11 @@ synchronized AmazonAsyncS3WithCredentials buildClient(
174
174
final AwsCredentialsProvider credentials = buildCredentials (logger , clientSettings );
175
175
builder .credentialsProvider (credentials );
176
176
177
- String endpoint = Strings .hasLength (clientSettings .endpoint ) ? clientSettings .endpoint : DEFAULT_S3_ENDPOINT ;
177
+ String s3Endpoint = Strings .hasText (clientSettings .region )
178
+ ? "s3." + Region .of (clientSettings .region ).toString () + ".amazonaws.com"
179
+ : GLOBAL_S3_ENDPOINT ;
180
+
181
+ String endpoint = Strings .hasLength (clientSettings .endpoint ) ? clientSettings .endpoint : s3Endpoint ;
178
182
if ((endpoint .startsWith ("http://" ) || endpoint .startsWith ("https://" )) == false ) {
179
183
// Manually add the schema to the endpoint to work around https://github.com/aws/aws-sdk-java/issues/2274
180
184
endpoint = clientSettings .protocol .toString () + "://" + endpoint ;
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ class S3Service implements Closeable {
98
98
99
99
private static final String STS_ENDPOINT_OVERRIDE_SYSTEM_PROPERTY = "aws.stsEndpointOverride" ;
100
100
101
- private static final String DEFAULT_S3_ENDPOINT = "s3.amazonaws.com" ;
101
+ private static final String GLOBAL_S3_ENDPOINT = "s3.amazonaws.com" ;
102
102
103
103
private volatile Map <S3ClientSettings , AmazonS3Reference > clientsCache = emptyMap ();
104
104
@@ -204,7 +204,11 @@ AmazonS3WithCredentials buildClient(final S3ClientSettings clientSettings) {
204
204
builder .httpClientBuilder (buildHttpClient (clientSettings ));
205
205
builder .overrideConfiguration (buildOverrideConfiguration (clientSettings ));
206
206
207
- String endpoint = Strings .hasLength (clientSettings .endpoint ) ? clientSettings .endpoint : DEFAULT_S3_ENDPOINT ;
207
+ String s3Endpoint = Strings .hasText (clientSettings .region )
208
+ ? "s3." + Region .of (clientSettings .region ).toString () + ".amazonaws.com"
209
+ : GLOBAL_S3_ENDPOINT ;
210
+
211
+ String endpoint = Strings .hasLength (clientSettings .endpoint ) ? clientSettings .endpoint : s3Endpoint ;
208
212
if ((endpoint .startsWith ("http://" ) || endpoint .startsWith ("https://" )) == false ) {
209
213
// Manually add the schema to the endpoint to work around https://github.com/aws/aws-sdk-java/issues/2274
210
214
// TODO: Remove this once fixed in the AWS SDK
You can’t perform that action at this time.
0 commit comments