From 95d8b9f630b844b46ee926493f8e0c0f458761fc Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Fri, 27 Oct 2023 14:32:42 -0400 Subject: [PATCH] s3 auto resolve fix --- flow/connectors/utils/aws.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/flow/connectors/utils/aws.go b/flow/connectors/utils/aws.go index 5e35828960..5ba14d1616 100644 --- a/flow/connectors/utils/aws.go +++ b/flow/connectors/utils/aws.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" ) @@ -101,10 +102,16 @@ func CreateS3Client(s3Creds S3PeerCredentials) (*s3.S3, error) { return nil, fmt.Errorf("failed to get AWS secrets: %w", err) } - sess := session.Must(session.NewSession(&aws.Config{ + config := &aws.Config{ Region: aws.String(awsSecrets.Region), Endpoint: aws.String(awsSecrets.Endpoint), - })) + } + + if s3Creds.AccessKeyID != "" && s3Creds.SecretAccessKey != "" { + config.Credentials = credentials.NewStaticCredentials(s3Creds.AccessKeyID, s3Creds.SecretAccessKey, "") + } + + sess := session.Must(session.NewSession(config)) s3svc := s3.New(sess) return s3svc, nil