Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private void initialize() throws Exception {
this.folder = folder;

this.client = buildS3Client(accessKey, secretKey, endpointValue, clientRegion);
this.presigner = buildS3Presinger(accessKey, secretKey, clientRegion);
this.presigner = buildS3Presigner(accessKey, secretKey, clientRegion);
bucketExists();
}
}
Expand All @@ -131,21 +131,20 @@ private S3Client buildS3Client(String accessKey, String secretKey, String endpoi

boolean bUseIAM = !getPropertyValue(USE_IAM, "", "").isEmpty() || (accessKey.equals("") && secretKey.equals(""));

S3ClientBuilder builder = bUseIAM ?
S3Client.builder() :
S3Client.builder().credentialsProvider(
StaticCredentialsProvider.create(
AwsBasicCredentials.create(accessKey, secretKey)
)
);
S3ClientBuilder builder = bUseIAM
? S3Client.builder().credentialsProvider(DefaultCredentialsProvider.create())
: S3Client.builder().credentialsProvider(
StaticCredentialsProvider.create(
AwsBasicCredentials.create(accessKey, secretKey)
)
);

if (bUseIAM) {
logger.debug("Using IAM Credentials");
}

if (!endpoint.isEmpty() && !endpoint.contains(".amazonaws.com")) {
pathStyleUrls = true;

s3Client = builder
.endpointOverride(URI.create(endpoint))
.region(Region.of(region))
Expand Down Expand Up @@ -181,11 +180,22 @@ private S3Client buildS3Client(String accessKey, String secretKey, String endpoi
return s3Client;
}

private S3Presigner buildS3Presinger(String accessKey, String secretKey, String region) {
return S3Presigner.builder()
private S3Presigner buildS3Presigner(String accessKey, String secretKey, String region) {
boolean bUseIAM = !getPropertyValue(USE_IAM, "", "").isEmpty() || (accessKey.equals("") && secretKey.equals(""));

S3Presigner.Builder builder = S3Presigner.builder()
.region(Region.of(region))
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(accessKey, secretKey)))
.build();
.credentialsProvider(
bUseIAM
? DefaultCredentialsProvider.create()
: StaticCredentialsProvider.create(AwsBasicCredentials.create(accessKey, secretKey))
);

if (bUseIAM) {
logger.debug("Using IAM Credentials for presigner");
}

return builder.build();
}

private void bucketExists() {
Expand Down
Loading