Skip to content

Commit 9b9f2b9

Browse files
make the v2 creds provider be the default
Signed-off-by: swatimodi-scout <swati.modi@scoutmotors.com>
1 parent 623adfc commit 9b9f2b9

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

bindings/aws/kinesis/kinesis.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ type AWSKinesis struct {
5353
closed atomic.Bool
5454
closeCh chan struct{}
5555
wg sync.WaitGroup
56+
// applicationName is required for KCL (Kinesis Client Library) worker configuration
57+
// in shared throughput mode. It identifies the consumer application and is used
58+
// for DynamoDB table naming and checkpointing.
5659
applicationName string
5760
}
5861

common/authentication/aws/client.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"sync"
2020

2121
"github.com/aws/aws-sdk-go-v2/aws"
22+
awsv2config "github.com/aws/aws-sdk-go-v2/config"
2223
v2creds "github.com/aws/aws-sdk-go-v2/credentials"
2324
"github.com/aws/aws-sdk-go/aws/credentials"
2425
"github.com/aws/aws-sdk-go/aws/session"
@@ -199,10 +200,19 @@ func (c *KinesisClients) WorkerCfg(ctx context.Context, stream, region, mode, ap
199200
const sharedMode = "shared"
200201
if c.Kinesis != nil {
201202
if mode == sharedMode {
202-
v1Creds, err := c.Credentials.Get()
203-
if err != nil {
203+
// Try v2 default config first (standard approach for v2 components)
204+
v2Config, err := awsv2config.LoadDefaultConfig(ctx, awsv2config.WithRegion(region))
205+
if err == nil {
206+
kclConfig := config.NewKinesisClientLibConfigWithCredential(applicationName, stream, region, "", v2Config.Credentials)
207+
return kclConfig
208+
}
209+
// Fallback to v1 credentials if v2 fails
210+
v1Creds, v1Err := c.Credentials.Get()
211+
if v1Err != nil {
212+
// Both v2 and v1 failed, return nil
204213
return nil
205214
}
215+
// Convert v1 credentials to v2 format
206216
v2Creds := v2creds.NewStaticCredentialsProvider(v1Creds.AccessKeyID, v1Creds.SecretAccessKey, v1Creds.SessionToken)
207217
kclConfig := config.NewKinesisClientLibConfigWithCredential(applicationName, stream, region, "", v2Creds)
208218
return kclConfig

0 commit comments

Comments
 (0)