diff --git a/awss3-storage/src/main/java/com/netflix/conductor/s3/config/S3Configuration.java b/awss3-storage/src/main/java/com/netflix/conductor/s3/config/S3Configuration.java index a188c85046..f4930e9c0b 100644 --- a/awss3-storage/src/main/java/com/netflix/conductor/s3/config/S3Configuration.java +++ b/awss3-storage/src/main/java/com/netflix/conductor/s3/config/S3Configuration.java @@ -21,6 +21,9 @@ import com.netflix.conductor.core.utils.IDGenerator; import com.netflix.conductor.s3.storage.S3PayloadStorage; +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.AmazonS3ClientBuilder; + @Configuration @EnableConfigurationProperties(S3Properties.class) @ConditionalOnProperty(name = "conductor.external-payload-storage.type", havingValue = "s3") @@ -28,7 +31,16 @@ public class S3Configuration { @Bean public ExternalPayloadStorage s3ExternalPayloadStorage( - IDGenerator idGenerator, S3Properties properties) { - return new S3PayloadStorage(idGenerator, properties); + IDGenerator idGenerator, S3Properties properties, AmazonS3 s3Client) { + return new S3PayloadStorage(idGenerator, properties, s3Client); + } + + @ConditionalOnProperty( + name = "conductor.external-payload-storage.s3.use_default_client", + havingValue = "true", + matchIfMissing = true) + @Bean + public AmazonS3 amazonS3() { + return AmazonS3ClientBuilder.standard().withRegion(region).build(); } } diff --git a/awss3-storage/src/main/java/com/netflix/conductor/s3/storage/S3PayloadStorage.java b/awss3-storage/src/main/java/com/netflix/conductor/s3/storage/S3PayloadStorage.java index 8ac530ea54..32bbf55a0c 100644 --- a/awss3-storage/src/main/java/com/netflix/conductor/s3/storage/S3PayloadStorage.java +++ b/awss3-storage/src/main/java/com/netflix/conductor/s3/storage/S3PayloadStorage.java @@ -30,7 +30,6 @@ import com.amazonaws.HttpMethod; import com.amazonaws.SdkClientException; import com.amazonaws.services.s3.AmazonS3; -import com.amazonaws.services.s3.AmazonS3ClientBuilder; import com.amazonaws.services.s3.model.*; /** @@ -52,12 +51,12 @@ public class S3PayloadStorage implements ExternalPayloadStorage { private final String bucketName; private final long expirationSec; - public S3PayloadStorage(IDGenerator idGenerator, S3Properties properties) { + public S3PayloadStorage(IDGenerator idGenerator, S3Properties properties, AmazonS3 s3Client) { this.idGenerator = idGenerator; + this.s3Client = s3Client; bucketName = properties.getBucketName(); expirationSec = properties.getSignedUrlExpirationDuration().getSeconds(); String region = properties.getRegion(); - s3Client = AmazonS3ClientBuilder.standard().withRegion(region).build(); } /**