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