Skip to content

Commit 2eddb15

Browse files
make the v2 creds provider be the default
Signed-off-by: swatimodi-scout <swati.modi@scoutmotors.com>
1 parent 920ad8a commit 2eddb15

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

bindings/aws/kinesis/kinesis.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ type AWSKinesis struct {
4949
consumerARN *string
5050
logger logger.Logger
5151
consumerMode string
52-
53-
closed atomic.Bool
54-
closeCh chan struct{}
55-
wg sync.WaitGroup
52+
closed atomic.Bool
53+
closeCh chan struct{}
54+
wg sync.WaitGroup
55+
// applicationName is required for KCL (Kinesis Client Library) worker configuration
56+
// in shared throughput mode. It identifies the consumer application and is used
57+
// for DynamoDB table naming and checkpointing.
58+
applicationName string
5659
}
5760

5861
// TODO: we need to clean up the metadata fields here and update this binding to use the builtin aws auth provider and reflect in metadata.yaml

common/authentication/aws/client.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import (
1717
"context"
1818
"errors"
1919
"sync"
20-
21-
"github.com/aws/aws-sdk-go/aws"
20+
"github.com/aws/aws-sdk-go-v2/aws"
21+
awsv2config "github.com/aws/aws-sdk-go-v2/config"
22+
v2creds "github.com/aws/aws-sdk-go-v2/credentials"
2223
"github.com/aws/aws-sdk-go/aws/credentials"
2324
"github.com/aws/aws-sdk-go/aws/session"
2425
"github.com/aws/aws-sdk-go/service/dynamodb"
@@ -193,12 +194,31 @@ func (c *KinesisClients) WorkerCfg(ctx context.Context, stream, consumer, mode s
193194
const sharedMode = "shared"
194195
if c.Kinesis != nil {
195196
if mode == sharedMode {
197+
<<<<<<< HEAD
196198
if c.Credentials != nil {
197199
kclConfig := config.NewKinesisClientLibConfigWithCredential(consumer,
198200
stream, c.Region, consumer,
199201
c.Credentials)
200202
return kclConfig
201203
}
204+
=======
205+
// Try v2 default config first (standard approach for v2 components)
206+
v2Config, err := awsv2config.LoadDefaultConfig(ctx, awsv2config.WithRegion(region))
207+
if err == nil {
208+
kclConfig := config.NewKinesisClientLibConfigWithCredential(applicationName, stream, region, "", v2Config.Credentials)
209+
return kclConfig
210+
}
211+
// Fallback to v1 credentials if v2 fails
212+
v1Creds, v1Err := c.Credentials.Get()
213+
if v1Err != nil {
214+
// Both v2 and v1 failed, return nil
215+
return nil
216+
}
217+
// Convert v1 credentials to v2 format
218+
v2Creds := v2creds.NewStaticCredentialsProvider(v1Creds.AccessKeyID, v1Creds.SecretAccessKey, v1Creds.SessionToken)
219+
kclConfig := config.NewKinesisClientLibConfigWithCredential(applicationName, stream, region, "", v2Creds)
220+
return kclConfig
221+
>>>>>>> 9b9f2b98 (make the v2 creds provider be the default)
202222
}
203223
}
204224

0 commit comments

Comments
 (0)