Skip to content

Commit 7e195c2

Browse files
authored
Update AWS SDK to 1.11.406 in repository-s3 (#30723)
1 parent 23f12e4 commit 7e195c2

File tree

10 files changed

+35
-21
lines changed

10 files changed

+35
-21
lines changed

plugins/repository-s3/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,23 @@ esplugin {
3232
}
3333

3434
versions << [
35-
'aws': '1.11.223'
35+
'aws': '1.11.406'
3636
]
3737

3838
dependencies {
3939
compile "com.amazonaws:aws-java-sdk-s3:${versions.aws}"
4040
compile "com.amazonaws:aws-java-sdk-kms:${versions.aws}"
4141
compile "com.amazonaws:aws-java-sdk-core:${versions.aws}"
42+
compile "com.amazonaws:jmespath-java:${versions.aws}"
4243
compile "org.apache.httpcomponents:httpclient:${versions.httpclient}"
4344
compile "org.apache.httpcomponents:httpcore:${versions.httpcore}"
4445
compile "commons-logging:commons-logging:${versions.commonslogging}"
4546
compile "commons-codec:commons-codec:${versions.commonscodec}"
47+
compile "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
4648
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.7.1'
4749
compile 'com.fasterxml.jackson.core:jackson-annotations:2.6.0'
50+
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}"
51+
compile 'joda-time:joda-time:2.10'
4852

4953
// HACK: javax.xml.bind was removed from default modules in java 9, so we pull the api in here,
5054
// and whitelist this hack in JarHell
@@ -53,6 +57,7 @@ dependencies {
5357

5458
dependencyLicenses {
5559
mapping from: /aws-java-sdk-.*/, to: 'aws-java-sdk'
60+
mapping from: /jmespath-java.*/, to: 'aws-java-sdk'
5661
mapping from: /jackson-.*/, to: 'jackson'
5762
mapping from: /jaxb-.*/, to: 'jaxb'
5863
}

plugins/repository-s3/licenses/aws-java-sdk-core-1.11.223.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
43f3b7332d4d527bbf34d4ac6be094f3dabec6de

plugins/repository-s3/licenses/aws-java-sdk-kms-1.11.223.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
e29854e58dc20f5453c1da7e580a5921b1e9714a

plugins/repository-s3/licenses/aws-java-sdk-s3-1.11.223.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5c3c2c57b076602b3aeef841c63e5848ec52b00d
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
06c291d1029943d4968a36fadffa3b71a6d8b4e4

plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3Service.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
import com.amazonaws.auth.AWSCredentials;
2424
import com.amazonaws.auth.AWSCredentialsProvider;
2525
import com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper;
26+
import com.amazonaws.client.builder.AwsClientBuilder;
2627
import com.amazonaws.http.IdleConnectionReaper;
2728
import com.amazonaws.internal.StaticCredentialsProvider;
2829
import com.amazonaws.services.s3.AmazonS3;
29-
import com.amazonaws.services.s3.AmazonS3Client;
30+
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
31+
import com.amazonaws.services.s3.internal.Constants;
3032
import org.apache.logging.log4j.Logger;
3133
import org.elasticsearch.common.Strings;
3234
import org.elasticsearch.common.collect.MapBuilder;
@@ -93,19 +95,26 @@ public AmazonS3Reference client(String clientName) {
9395
}
9496
}
9597

96-
private AmazonS3 buildClient(S3ClientSettings clientSettings) {
97-
final AWSCredentialsProvider credentials = buildCredentials(logger, clientSettings);
98-
final ClientConfiguration configuration = buildConfiguration(clientSettings);
99-
final AmazonS3 client = buildClient(credentials, configuration);
100-
if (Strings.hasText(clientSettings.endpoint)) {
101-
client.setEndpoint(clientSettings.endpoint);
102-
}
103-
return client;
104-
}
105-
10698
// proxy for testing
107-
AmazonS3 buildClient(AWSCredentialsProvider credentials, ClientConfiguration configuration) {
108-
return new AmazonS3Client(credentials, configuration);
99+
AmazonS3 buildClient(final S3ClientSettings clientSettings) {
100+
final AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();
101+
builder.withCredentials(buildCredentials(logger, clientSettings));
102+
builder.withClientConfiguration(buildConfiguration(clientSettings));
103+
104+
final String endpoint = Strings.hasLength(clientSettings.endpoint) ? clientSettings.endpoint : Constants.S3_HOSTNAME;
105+
logger.debug("using endpoint [{}]", endpoint);
106+
107+
// If the endpoint configuration isn't set on the builder then the default behaviour is to try
108+
// and work out what region we are in and use an appropriate endpoint - see AwsClientBuilder#setRegion.
109+
// In contrast, directly-constructed clients use s3.amazonaws.com unless otherwise instructed. We currently
110+
// use a directly-constructed client, and need to keep the existing behaviour to avoid a breaking change,
111+
// so to move to using the builder we must set it explicitly to keep the existing behaviour.
112+
//
113+
// We do this because directly constructing the client is deprecated (was already deprecated in 1.1.223 too)
114+
// so this change removes that usage of a deprecated API.
115+
builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, null));
116+
117+
return builder.build();
109118
}
110119

111120
// pkg private for tests

plugins/repository-s3/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.elasticsearch.repositories.s3;
2121

22-
import com.amazonaws.ClientConfiguration;
2322
import com.amazonaws.auth.AWSCredentials;
2423
import com.amazonaws.auth.AWSCredentialsProvider;
2524
import com.amazonaws.services.s3.AmazonS3;
@@ -70,9 +69,9 @@ static final class ProxyS3Service extends S3Service {
7069
}
7170

7271
@Override
73-
AmazonS3 buildClient(AWSCredentialsProvider credentials, ClientConfiguration configuration) {
74-
final AmazonS3 client = super.buildClient(credentials, configuration);
75-
return new ClientAndCredentials(client, credentials);
72+
AmazonS3 buildClient(final S3ClientSettings clientSettings) {
73+
final AmazonS3 client = super.buildClient(clientSettings);
74+
return new ClientAndCredentials(client, buildCredentials(logger, clientSettings));
7675
}
7776

7877
}

0 commit comments

Comments
 (0)