From 2b06d3eebfacd42280fc61d2a54390909271c110 Mon Sep 17 00:00:00 2001 From: Ryan Lewon Date: Tue, 28 Jun 2022 18:50:15 -0400 Subject: [PATCH] Updated INSTANCE_PROFILE to use AWSDefaultProfileCredential. --- .../destination/s3/S3DestinationConfig.java | 6 ++--- .../S3AWSDefaultProfileCredentialConfig.java | 22 +++++++++++++++++++ .../s3/credential/S3CredentialType.java | 2 +- 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/credential/S3AWSDefaultProfileCredentialConfig.java diff --git a/airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/S3DestinationConfig.java b/airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/S3DestinationConfig.java index 34bfed0eb745..7dd2950dd2b6 100644 --- a/airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/S3DestinationConfig.java +++ b/airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/S3DestinationConfig.java @@ -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; @@ -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); @@ -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) diff --git a/airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/credential/S3AWSDefaultProfileCredentialConfig.java b/airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/credential/S3AWSDefaultProfileCredentialConfig.java new file mode 100644 index 000000000000..188e493cfa51 --- /dev/null +++ b/airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/credential/S3AWSDefaultProfileCredentialConfig.java @@ -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(); + } + +} diff --git a/airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/credential/S3CredentialType.java b/airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/credential/S3CredentialType.java index 6c96c6f8273c..b050482543f3 100644 --- a/airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/credential/S3CredentialType.java +++ b/airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/credential/S3CredentialType.java @@ -7,6 +7,6 @@ public enum S3CredentialType { ACCESS_KEY, - INSTANCE_PROFILE + DEFAULT_PROFILE }