Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3699 from PavelShahoiko/feature/make-s3-as-depend…
Browse files Browse the repository at this point in the history
…enty

Added the ability to inject a custom AmazonS3 client
  • Loading branch information
v1r3n authored Jul 23, 2023
2 parents fc8a206 + a469abd commit 728925f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,26 @@
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")
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(S3Properties properties) {
return AmazonS3ClientBuilder.standard().withRegion(properties.getRegion()).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

/**
Expand All @@ -52,12 +51,11 @@ 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();
}

/**
Expand Down

0 comments on commit 728925f

Please sign in to comment.