diff --git a/docs/src/main/asciidoc/spring-cloud-config.adoc b/docs/src/main/asciidoc/spring-cloud-config.adoc
index b53317280..735d364a9 100644
--- a/docs/src/main/asciidoc/spring-cloud-config.adoc
+++ b/docs/src/main/asciidoc/spring-cloud-config.adoc
@@ -340,17 +340,17 @@ This helper is not used with the JGit library, so a JGit CredentialProvider for
AWS CodeCommit URIs follow this pattern:
```bash
-https//git-codecommit.${AWS_REGION}.amazonaws.com/v1/repos/${repo}.
+https://git-codecommit.${AWS_REGION}.amazonaws.com/v1/repos/${repo}
```
If you provide a username and password with an AWS CodeCommit URI, they must be the https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html[AWS accessKeyId and secretAccessKey] that provide access to the repository.
-If you do not specify a username and password, the accessKeyId and secretAccessKey are retrieved by using the https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html[AWS Default Credential Provider Chain].
+If you do not specify a username and password, the accessKeyId and secretAccessKey are retrieved by using the https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/credentials.html[Default Credential Provider Chain].
If your Git URI matches the CodeCommit URI pattern (shown earlier), you must provide valid AWS credentials in the username and password or in one of the locations supported by the default credential provider chain.
AWS EC2 instances may use https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html[IAM Roles for EC2 Instances].
-NOTE: The `aws-java-sdk-core` jar is an optional dependency.
-If the `aws-java-sdk-core` jar is not on your classpath, the AWS Code Commit credential provider is not created, regardless of the git server URI.
+NOTE: The `software.amazon.awssdk:auth` jar is an optional dependency.
+If the `software.amazon.awssdk:auth` jar is not on your classpath, the AWS Code Commit credential provider is not created, regardless of the git server URI.
===== Authentication with Google Cloud Source
@@ -940,15 +940,15 @@ NOTE: When no profile is specified `default` will be used.
==== AWS S3 Backend
Spring Cloud Config Server supports AWS S3 as a backend for configuration properties.
-You can enable this feature by adding a dependency to the link:https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/examples-s3.html[AWS Java SDK For Amazon S3].
+You can enable this feature by adding a dependency to the link:https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/examples-s3.html[AWS Java SDK For Amazon S3].
[source,xml,indent=0]
.pom.xml
----
- com.amazonaws
- aws-java-sdk-s3
+ software.amazon.awssdk
+ s3
----
@@ -970,7 +970,7 @@ spring:
It is also possible to specify an AWS URL to link:https://aws.amazon.com/blogs/developer/using-new-regions-and-endpoints/[override the standard endpoint] of your S3 service with `spring.cloud.config.server.awss3.endpoint`. This allows support for beta regions of S3, and other S3 compatible storage APIs.
-Credentials are found using the link:https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html[Default AWS Credential Provider Chain]. Versioned and encrypted buckets are supported without further configuration.
+Credentials are found using the link:https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/credentials.html[Default Credential Provider Chain]. Versioned and encrypted buckets are supported without further configuration.
Configuration files are stored in your bucket as `{application}-{profile}.properties`, `{application}-{profile}.yml` or `{application}-{profile}.json`. An optional label can be provided to specify a directory path to the file.
@@ -978,14 +978,14 @@ NOTE: When no profile is specified `default` will be used.
==== AWS Parameter Store Backend
-Spring Cloud Config Server supports AWS Parameter Store as a backend for configuration properties. You can enable this feature by adding a dependency to the link:https://github.com/aws/aws-sdk-java/tree/master/aws-java-sdk-ssm[AWS Java SDK for SSM].
+Spring Cloud Config Server supports AWS Parameter Store as a backend for configuration properties. You can enable this feature by adding a dependency to the link:https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/examples-ssm.html[AWS Java SDK for SSM].
[source,xml,indent=0]
.pom.xml
----
- com.amazonaws
- aws-java-sdk-ssm
+ software.amazon.awssdk
+ ssm
----
@@ -1019,7 +1019,7 @@ The following table describes the AWS Parameter Store configuration properties.
|*region*
|no
|
-|The region to be used by the AWS Parameter Store client. If it's not explicitly set, the SDK tries to determine the region to use by using the link:https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/java-dg-region-selection.html#default-region-provider-chain[Default Region Provider Chain].
+|The region to be used by the AWS Parameter Store client. If it's not explicitly set, the SDK tries to determine the region to use by using the link:https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/region-selection.html#default-region-provider-chain[Default Region Provider Chain].
|*endpoint*
|no
@@ -1058,7 +1058,7 @@ The following table describes the AWS Parameter Store configuration properties.
|===
-AWS Parameter Store API credentials are determined using the link:https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html#credentials-default[Default Credential Provider Chain].
+AWS Parameter Store API credentials are determined using the link:https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/credentials.html#credentials-default[Default Credential Provider Chain].
Versioned parameters are already supported with the default behaviour of returning the latest version.
[NOTE]
@@ -1072,14 +1072,14 @@ Versioned parameters are already supported with the default behaviour of returni
==== AWS Secrets Manager Backend
Spring Cloud Config Server supports link:https://aws.amazon.com/secrets-manager/[AWS Secrets Manager] as a backend for configuration properties.
-You can enable this feature by adding a dependency to link:https://github.com/aws/aws-sdk-java/tree/master/aws-java-sdk-secretsmanager[AWS Java SDK for Secrets Manager].
+You can enable this feature by adding a dependency to link:https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/examples-secretsmanager.html[AWS Java SDK for Secrets Manager].
[source,xml,indent=0]
.pom.xml
----
- com.amazonaws
- aws-java-sdk-secretsmanager
+ software.amazon.awssdk
+ secretsmanager
----
@@ -1102,7 +1102,7 @@ spring:
----
-AWS Secrets Manager API credentials are determined using link:https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html#credentials-default[Default Credential Provider Chain].
+AWS Secrets Manager API credentials are determined using link:https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/credentials.html#credentials-default[Default Credential Provider Chain].
[NOTE]
====
diff --git a/pom.xml b/pom.xml
index 173f0a777..d78c7e99b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,9 +28,10 @@
config4.0.0-SNAPSHOT
- 1.11.911
+ 2.17.195v1-rev20201112-1.30.101.16.2
+ 1.12.2202.31.0truetrue
@@ -71,23 +72,23 @@
${spring-cloud-commons.version}
- com.amazonaws
- aws-java-sdk-core
+ software.amazon.awssdk
+ auth${aws-java-sdk.version}
- com.amazonaws
- aws-java-sdk-s3
+ software.amazon.awssdk
+ s3${aws-java-sdk.version}
- com.amazonaws
- aws-java-sdk-secretsmanager
+ software.amazon.awssdk
+ secretsmanager${aws-java-sdk.version}
- com.amazonaws
- aws-java-sdk-ssm
+ software.amazon.awssdk
+ ssm${aws-java-sdk.version}
@@ -116,8 +117,13 @@
${testcontainers.version}pomimport
-
-
+
+
+ com.amazonaws
+ aws-java-sdk-core
+ ${aws-java-sdk-v1.version}
+
+ com.github.tomakehurstwiremock-jre8${wiremock.version}
diff --git a/spring-cloud-config-dependencies/pom.xml b/spring-cloud-config-dependencies/pom.xml
index 7527edf82..1dce92968 100644
--- a/spring-cloud-config-dependencies/pom.xml
+++ b/spring-cloud-config-dependencies/pom.xml
@@ -16,7 +16,7 @@
Spring Cloud Config Dependencies5.12.0.202106070339-r
- 2.3.2
+ 3.0.0-M12.1.1.RELEASE
diff --git a/spring-cloud-config-sample/src/test/java/sample/ConfigDataOrderingVaultIntegrationTests.java b/spring-cloud-config-sample/src/test/java/sample/ConfigDataOrderingVaultIntegrationTests.java
index 5a44345b2..46fafcfb1 100644
--- a/spring-cloud-config-sample/src/test/java/sample/ConfigDataOrderingVaultIntegrationTests.java
+++ b/spring-cloud-config-sample/src/test/java/sample/ConfigDataOrderingVaultIntegrationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018-2019 the original author or authors.
+ * Copyright 2018-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
import org.json.JSONException;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.BindMode;
import org.testcontainers.junit.jupiter.Container;
@@ -42,6 +43,7 @@
* vaultordering/client-dev.yml
*/
@Testcontainers
+@Tag("DockerRequired")
public class ConfigDataOrderingVaultIntegrationTests {
private static final int configServerPort = TestSocketUtils.findAvailableTcpPort();
diff --git a/spring-cloud-config-server/pom.xml b/spring-cloud-config-server/pom.xml
index 63564e62b..2cf69b950 100644
--- a/spring-cloud-config-server/pom.xml
+++ b/spring-cloud-config-server/pom.xml
@@ -94,23 +94,23 @@
true
- com.amazonaws
- aws-java-sdk-core
+ software.amazon.awssdk
+ authtrue
- com.amazonaws
- aws-java-sdk-s3
+ software.amazon.awssdk
+ s3true
- com.amazonaws
- aws-java-sdk-secretsmanager
+ software.amazon.awssdk
+ secretsmanagertrue
- com.amazonaws
- aws-java-sdk-ssm
+ software.amazon.awssdk
+ ssmtrue
@@ -168,6 +168,16 @@
junit-jupitertest
+
+ org.testcontainers
+ localstack
+ test
+
+
+ com.amazonaws
+ aws-java-sdk-core
+ test
+ com.github.tomakehurstwiremock-jre8
diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/config/EnvironmentRepositoryConfiguration.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/config/EnvironmentRepositoryConfiguration.java
index 57cee54e6..7dc63d527 100644
--- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/config/EnvironmentRepositoryConfiguration.java
+++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/config/EnvironmentRepositoryConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2020 the original author or authors.
+ * Copyright 2013-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,14 +19,14 @@
import java.util.List;
import java.util.Optional;
-import com.amazonaws.services.s3.AmazonS3;
-import com.amazonaws.services.secretsmanager.AWSSecretsManager;
-import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement;
import com.google.cloud.secretmanager.v1.SecretManagerServiceClient;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.http.client.HttpClient;
import org.eclipse.jgit.api.TransportConfigCallback;
import org.tmatesoft.svn.core.SVNException;
+import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
+import software.amazon.awssdk.services.ssm.SsmClient;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
@@ -210,7 +210,7 @@ public ConfigurableHttpConnectionFactory httpClientConnectionFactory() {
}
@Configuration(proxyBeanMethods = false)
- @ConditionalOnClass(AmazonS3.class)
+ @ConditionalOnClass(S3Client.class)
static class AwsS3FactoryConfig {
@Bean
@@ -221,7 +221,7 @@ public AwsS3EnvironmentRepositoryFactory awsS3EnvironmentRepositoryFactory(Confi
}
@Configuration(proxyBeanMethods = false)
- @ConditionalOnClass(AWSSecretsManager.class)
+ @ConditionalOnClass(SecretsManagerClient.class)
static class AwsSecretsManagerFactoryConfig {
@Bean
@@ -233,7 +233,7 @@ public AwsSecretsManagerEnvironmentRepositoryFactory awsSecretsManagerEnvironmen
}
@Configuration(proxyBeanMethods = false)
- @ConditionalOnClass(AWSSimpleSystemsManagement.class)
+ @ConditionalOnClass(SsmClient.class)
static class AwsParameterStoreFactoryConfig {
@Bean
diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsClientBuilderConfigurer.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsClientBuilderConfigurer.java
index 46b4f4a0c..b47931bd7 100644
--- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsClientBuilderConfigurer.java
+++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsClientBuilderConfigurer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018-2020 the original author or authors.
+ * Copyright 2018-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,10 @@
package org.springframework.cloud.config.server.environment;
-import com.amazonaws.client.builder.AwsClientBuilder;
-import com.amazonaws.client.builder.AwsSyncClientBuilder;
+import java.net.URI;
+
+import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder;
+import software.amazon.awssdk.regions.Region;
import org.springframework.util.StringUtils;
@@ -26,15 +28,11 @@ abstract class AwsClientBuilderConfigurer {
private AwsClientBuilderConfigurer() {
}
- static void configureClientBuilder(AwsSyncClientBuilder, ?> clientBuilder, String region, String endpoint) {
+ static void configureClientBuilder(AwsClientBuilder, ?> clientBuilder, String region, String endpoint) {
if (StringUtils.hasText(region)) {
+ clientBuilder.region(Region.of(region));
if (StringUtils.hasText(endpoint)) {
- AwsClientBuilder.EndpointConfiguration endpointConfiguration = new AwsClientBuilder.EndpointConfiguration(
- endpoint, region);
- clientBuilder.withEndpointConfiguration(endpointConfiguration);
- }
- else {
- clientBuilder.withRegion(region);
+ clientBuilder.endpointOverride(URI.create(endpoint));
}
}
}
diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsParameterStoreEnvironmentRepository.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsParameterStoreEnvironmentRepository.java
index 5bb5f0824..1b9532b63 100644
--- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsParameterStoreEnvironmentRepository.java
+++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsParameterStoreEnvironmentRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2020 the original author or authors.
+ * Copyright 2013-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,10 +26,10 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement;
-import com.amazonaws.services.simplesystemsmanagement.model.GetParametersByPathRequest;
-import com.amazonaws.services.simplesystemsmanagement.model.GetParametersByPathResult;
-import com.amazonaws.services.simplesystemsmanagement.model.Parameter;
+import software.amazon.awssdk.services.ssm.SsmClient;
+import software.amazon.awssdk.services.ssm.model.GetParametersByPathRequest;
+import software.amazon.awssdk.services.ssm.model.GetParametersByPathResponse;
+import software.amazon.awssdk.services.ssm.model.Parameter;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.environment.PropertySource;
@@ -43,14 +43,13 @@
*/
public class AwsParameterStoreEnvironmentRepository implements EnvironmentRepository {
- private final AWSSimpleSystemsManagement awsSsmClient;
+ private final SsmClient awsSsmClient;
private final ConfigServerProperties configServerProperties;
private final AwsParameterStoreEnvironmentProperties environmentProperties;
- public AwsParameterStoreEnvironmentRepository(AWSSimpleSystemsManagement awsSsmClient,
- ConfigServerProperties configServerProperties,
+ public AwsParameterStoreEnvironmentRepository(SsmClient awsSsmClient, ConfigServerProperties configServerProperties,
AwsParameterStoreEnvironmentProperties environmentProperties) {
this.awsSsmClient = awsSsmClient;
this.configServerProperties = configServerProperties;
@@ -137,20 +136,20 @@ private List getPropertySources(Set parameterPaths) {
private Map getPropertiesByParameterPath(String path) {
Map result = new HashMap<>();
- GetParametersByPathRequest request = new GetParametersByPathRequest().withPath(path)
- .withRecursive(environmentProperties.isRecursive())
- .withWithDecryption(environmentProperties.isDecryptValues())
- .withMaxResults(environmentProperties.getMaxResults());
+ GetParametersByPathRequest request = GetParametersByPathRequest.builder().path(path)
+ .recursive(environmentProperties.isRecursive()).withDecryption(environmentProperties.isDecryptValues())
+ .maxResults(environmentProperties.getMaxResults()).build();
- GetParametersByPathResult response = awsSsmClient.getParametersByPath(request);
+ GetParametersByPathResponse response = awsSsmClient.getParametersByPath(request);
if (response != null) {
- addParametersToProperties(path, response.getParameters(), result);
+ addParametersToProperties(path, response.parameters(), result);
- while (StringUtils.hasLength(response.getNextToken())) {
- response = awsSsmClient.getParametersByPath(request.withNextToken(response.getNextToken()));
+ while (StringUtils.hasLength(response.nextToken())) {
+ response = awsSsmClient
+ .getParametersByPath(request.toBuilder().nextToken(response.nextToken()).build());
- addParametersToProperties(path, response.getParameters(), result);
+ addParametersToProperties(path, response.parameters(), result);
}
}
@@ -159,9 +158,9 @@ private Map getPropertiesByParameterPath(String path) {
private void addParametersToProperties(String path, List parameters, Map properties) {
for (Parameter parameter : parameters) {
- String name = StringUtils.delete(parameter.getName(), path).replace(DEFAULT_PATH_SEPARATOR, ".");
+ String name = StringUtils.delete(parameter.name(), path).replace(DEFAULT_PATH_SEPARATOR, ".");
- properties.put(name, parameter.getValue());
+ properties.put(name, parameter.value());
}
}
diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsParameterStoreEnvironmentRepositoryFactory.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsParameterStoreEnvironmentRepositoryFactory.java
index 37117d170..ad0d37554 100644
--- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsParameterStoreEnvironmentRepositoryFactory.java
+++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsParameterStoreEnvironmentRepositoryFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018-2020 the original author or authors.
+ * Copyright 2018-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@
package org.springframework.cloud.config.server.environment;
-import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement;
-import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagementClientBuilder;
+import software.amazon.awssdk.services.ssm.SsmClient;
+import software.amazon.awssdk.services.ssm.SsmClientBuilder;
import org.springframework.cloud.config.server.config.ConfigServerProperties;
@@ -37,11 +37,11 @@ public AwsParameterStoreEnvironmentRepositoryFactory(ConfigServerProperties conf
@Override
public AwsParameterStoreEnvironmentRepository build(AwsParameterStoreEnvironmentProperties environmentProperties) {
- AWSSimpleSystemsManagementClientBuilder clientBuilder = AWSSimpleSystemsManagementClientBuilder.standard();
+ SsmClientBuilder clientBuilder = SsmClient.builder();
configureClientBuilder(clientBuilder, environmentProperties.getRegion(), environmentProperties.getEndpoint());
- AWSSimpleSystemsManagement client = clientBuilder.build();
+ SsmClient client = clientBuilder.build();
return new AwsParameterStoreEnvironmentRepository(client, configServerProperties, environmentProperties);
}
diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepository.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepository.java
index b3a528311..eb0a5dad0 100644
--- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepository.java
+++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2019 the original author or authors.
+ * Copyright 2013-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,10 +20,10 @@
import java.io.InputStream;
import java.util.Properties;
-import com.amazonaws.services.s3.AmazonS3;
-import com.amazonaws.services.s3.model.GetObjectRequest;
-import com.amazonaws.services.s3.model.S3Object;
-import com.amazonaws.services.s3.model.S3ObjectIdBuilder;
+import software.amazon.awssdk.core.ResponseInputStream;
+import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.s3.model.GetObjectRequest;
+import software.amazon.awssdk.services.s3.model.GetObjectResponse;
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
import org.springframework.cloud.config.environment.Environment;
@@ -31,6 +31,7 @@
import org.springframework.cloud.config.server.config.ConfigServerProperties;
import org.springframework.core.Ordered;
import org.springframework.core.io.InputStreamResource;
+import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
@@ -43,7 +44,7 @@ public class AwsS3EnvironmentRepository implements EnvironmentRepository, Ordere
private static final String PATH_SEPARATOR = "/";
- private final AmazonS3 s3Client;
+ private final S3Client s3Client;
private final String bucketName;
@@ -51,7 +52,7 @@ public class AwsS3EnvironmentRepository implements EnvironmentRepository, Ordere
protected int order = Ordered.LOWEST_PRECEDENCE;
- public AwsS3EnvironmentRepository(AmazonS3 s3Client, String bucketName, ConfigServerProperties server) {
+ public AwsS3EnvironmentRepository(S3Client s3Client, String bucketName, ConfigServerProperties server) {
this.s3Client = s3Client;
this.bucketName = bucketName;
this.serverProperties = server;
@@ -68,11 +69,11 @@ public void setOrder(int order) {
@Override
public Environment findOne(String specifiedApplication, String specifiedProfiles, String specifiedLabel) {
- final String application = StringUtils.isEmpty(specifiedApplication)
+ final String application = ObjectUtils.isEmpty(specifiedApplication)
? serverProperties.getDefaultApplicationName() : specifiedApplication;
- final String profiles = StringUtils.isEmpty(specifiedProfiles) ? serverProperties.getDefaultProfile()
+ final String profiles = ObjectUtils.isEmpty(specifiedProfiles) ? serverProperties.getDefaultProfile()
: specifiedProfiles;
- final String label = StringUtils.isEmpty(specifiedLabel) ? serverProperties.getDefaultLabel() : specifiedLabel;
+ final String label = ObjectUtils.isEmpty(specifiedLabel) ? serverProperties.getDefaultLabel() : specifiedLabel;
String[] profileArray = parseProfiles(profiles);
String[] apps = new String[] { application };
@@ -113,41 +114,40 @@ private String[] parseProfiles(String profiles) {
private S3ConfigFile getS3ConfigFile(String application, String profile, String label) {
String objectKeyPrefix = buildObjectKeyPrefix(application, profile, label);
- final S3ObjectIdBuilder s3ObjectIdBuilder = new S3ObjectIdBuilder().withBucket(bucketName);
+ final GetObjectRequest.Builder requestBuilder = GetObjectRequest.builder().bucket(bucketName);
- return getS3ConfigFile(s3ObjectIdBuilder, objectKeyPrefix);
+ return getS3ConfigFile(requestBuilder, objectKeyPrefix);
}
private String buildObjectKeyPrefix(String application, String profile, String label) {
StringBuilder objectKeyPrefix = new StringBuilder();
- if (!StringUtils.isEmpty(label)) {
+ if (StringUtils.hasLength(label)) {
objectKeyPrefix.append(label).append(PATH_SEPARATOR);
}
objectKeyPrefix.append(application);
- if (!StringUtils.isEmpty(profile)) {
+ if (StringUtils.hasLength(profile)) {
objectKeyPrefix.append("-").append(profile);
}
return objectKeyPrefix.toString();
}
- private S3ConfigFile getS3ConfigFile(S3ObjectIdBuilder s3ObjectIdBuilder, String keyPrefix) {
+ private S3ConfigFile getS3ConfigFile(GetObjectRequest.Builder requestBuilder, String keyPrefix) {
try {
- final S3Object properties = s3Client
- .getObject(new GetObjectRequest(s3ObjectIdBuilder.withKey(keyPrefix + ".properties").build()));
- return new PropertyS3ConfigFile(properties.getObjectMetadata().getVersionId(),
- properties.getObjectContent());
+ ResponseInputStream inputStream = s3Client
+ .getObject(requestBuilder.key(keyPrefix + ".properties").build());
+ return new PropertyS3ConfigFile(inputStream.response().versionId(), inputStream);
}
catch (Exception eProperties) {
try {
- final S3Object yaml = s3Client
- .getObject(new GetObjectRequest(s3ObjectIdBuilder.withKey(keyPrefix + ".yml").build()));
- return new YamlS3ConfigFile(yaml.getObjectMetadata().getVersionId(), yaml.getObjectContent());
+ ResponseInputStream inputStream = s3Client
+ .getObject(requestBuilder.key(keyPrefix + ".yml").build());
+ return new YamlS3ConfigFile(inputStream.response().versionId(), inputStream);
}
catch (Exception eYaml) {
try {
- final S3Object json = s3Client
- .getObject(new GetObjectRequest(s3ObjectIdBuilder.withKey(keyPrefix + ".json").build()));
- return new JsonS3ConfigFile(json.getObjectMetadata().getVersionId(), json.getObjectContent());
+ ResponseInputStream inputStream = s3Client
+ .getObject(requestBuilder.key(keyPrefix + ".json").build());
+ return new JsonS3ConfigFile(inputStream.response().versionId(), inputStream);
}
catch (Exception eJson) {
return null;
diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepositoryFactory.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepositoryFactory.java
index c79be96ac..e7efee3bd 100644
--- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepositoryFactory.java
+++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsS3EnvironmentRepositoryFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013-2019 the original author or authors.
+ * Copyright 2013-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@
package org.springframework.cloud.config.server.environment;
-import com.amazonaws.services.s3.AmazonS3;
-import com.amazonaws.services.s3.AmazonS3ClientBuilder;
+import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.s3.S3ClientBuilder;
import org.springframework.cloud.config.server.config.ConfigServerProperties;
@@ -34,9 +34,9 @@ public AwsS3EnvironmentRepositoryFactory(ConfigServerProperties server) {
@Override
public AwsS3EnvironmentRepository build(AwsS3EnvironmentProperties environmentProperties) {
- final AmazonS3ClientBuilder clientBuilder = AmazonS3ClientBuilder.standard();
+ final S3ClientBuilder clientBuilder = S3Client.builder();
configureClientBuilder(clientBuilder, environmentProperties.getRegion(), environmentProperties.getEndpoint());
- final AmazonS3 client = clientBuilder.build();
+ final S3Client client = clientBuilder.build();
AwsS3EnvironmentRepository repository = new AwsS3EnvironmentRepository(client,
environmentProperties.getBucket(), server);
diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsSecretsManagerEnvironmentRepository.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsSecretsManagerEnvironmentRepository.java
index 02b9a626f..ef243c1d3 100644
--- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsSecretsManagerEnvironmentRepository.java
+++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AwsSecretsManagerEnvironmentRepository.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018-2020 the original author or authors.
+ * Copyright 2018-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,19 +21,20 @@
import java.util.HashMap;
import java.util.Map;
-import com.amazonaws.services.secretsmanager.AWSSecretsManager;
-import com.amazonaws.services.secretsmanager.model.GetSecretValueRequest;
-import com.amazonaws.services.secretsmanager.model.GetSecretValueResult;
-import com.amazonaws.services.secretsmanager.model.ResourceNotFoundException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
+import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest;
+import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse;
+import software.amazon.awssdk.services.secretsmanager.model.ResourceNotFoundException;
import org.springframework.cloud.config.environment.Environment;
import org.springframework.cloud.config.environment.PropertySource;
import org.springframework.cloud.config.server.config.ConfigServerProperties;
import org.springframework.core.Ordered;
+import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import static org.springframework.cloud.config.server.environment.AwsSecretsManagerEnvironmentProperties.DEFAULT_PATH_SEPARATOR;
@@ -48,7 +49,7 @@ public class AwsSecretsManagerEnvironmentRepository implements EnvironmentReposi
private final ObjectMapper objectMapper;
- private final AWSSecretsManager awsSmClient;
+ private final SecretsManagerClient awsSmClient;
private final ConfigServerProperties configServerProperties;
@@ -56,7 +57,7 @@ public class AwsSecretsManagerEnvironmentRepository implements EnvironmentReposi
private final int order;
- public AwsSecretsManagerEnvironmentRepository(AWSSecretsManager awsSmClient,
+ public AwsSecretsManagerEnvironmentRepository(SecretsManagerClient awsSmClient,
ConfigServerProperties configServerProperties,
AwsSecretsManagerEnvironmentProperties environmentProperties) {
this.awsSmClient = awsSmClient;
@@ -71,11 +72,11 @@ public Environment findOne(String application, String profileList, String label)
final String defaultApplication = configServerProperties.getDefaultApplicationName();
final String defaultProfile = configServerProperties.getDefaultProfile();
- if (StringUtils.isEmpty(application)) {
+ if (ObjectUtils.isEmpty(application)) {
application = defaultApplication;
}
- if (StringUtils.isEmpty(profileList)) {
+ if (ObjectUtils.isEmpty(profileList)) {
profileList = defaultProfile;
}
@@ -135,18 +136,15 @@ private String buildPath(String application, String profile) {
private Map