Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/destination s3 default provider #14231

Merged
Merged
Show file tree
Hide file tree
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 @@ -13,7 +13,7 @@
import io.airbyte.integrations.destination.s3.credential.S3AccessKeyCredentialConfig;
import io.airbyte.integrations.destination.s3.credential.S3CredentialConfig;
import io.airbyte.integrations.destination.s3.credential.S3CredentialType;
import io.airbyte.integrations.destination.s3.credential.S3InstanceProfileCredentialConfig;
import io.airbyte.integrations.destination.s3.credential.S3AWSDefaultProfileCredentialConfig;
import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -88,7 +88,7 @@ public static S3DestinationConfig getS3DestinationConfig(final JsonNode config)
if (config.has("access_key_id")) {
credentialConfig = new S3AccessKeyCredentialConfig(config.get("access_key_id").asText(), config.get("secret_access_key").asText());
} else {
credentialConfig = new S3InstanceProfileCredentialConfig();
credentialConfig = new S3AWSDefaultProfileCredentialConfig();
}
builder = builder.withCredentialConfig(credentialConfig);

Expand Down Expand Up @@ -154,7 +154,7 @@ protected AmazonS3 createS3Client() {
final AWSCredentialsProvider credentialsProvider = credentialConfig.getS3CredentialsProvider();
final S3CredentialType credentialType = credentialConfig.getCredentialType();

if (credentialType == S3CredentialType.INSTANCE_PROFILE) {
if (credentialType == S3CredentialType.DEFAULT_PROFILE) {
return AmazonS3ClientBuilder.standard()
.withRegion(bucketRegion)
.withCredentials(credentialsProvider)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.integrations.destination.s3.credential;

import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;

public class S3AWSDefaultProfileCredentialConfig implements S3CredentialConfig {

@Override
public S3CredentialType getCredentialType() {
return S3CredentialType.DEFAULT_PROFILE;
}

@Override
public AWSCredentialsProvider getS3CredentialsProvider() {
return new DefaultAWSCredentialsProviderChain();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
public enum S3CredentialType {

ACCESS_KEY,
INSTANCE_PROFILE
DEFAULT_PROFILE

}