Skip to content

Commit

Permalink
Send ddb region as awsCfg
Browse files Browse the repository at this point in the history
  • Loading branch information
danielblando committed Mar 29, 2024
1 parent d0db754 commit 327792f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/ring/kv/dynamodb/dynamodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ func newDynamodbKV(cfg Config, logger log.Logger) (dynamodbKV, error) {
return dynamodbKV{}, err
}

awsCfg := aws.NewConfig()
if len(cfg.Region) > 0 {
sess.Config = &aws.Config{
Region: aws.String(cfg.Region),
}
awsCfg = awsCfg.WithRegion(cfg.Region)
}

dynamoDB := dynamodb.New(sess)
dynamoDB := dynamodb.New(sess, awsCfg)

ddbKV := &dynamodbKV{
ddbClient: dynamoDB,
Expand Down
7 changes: 7 additions & 0 deletions pkg/ring/kv/dynamodb/dynamodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dynamodb
import (
"context"
"fmt"
util_log "github.com/cortexproject/cortex/pkg/util/log"
"strconv"
"testing"
"time"
Expand All @@ -28,6 +29,12 @@ func Test_TTLDisabled(t *testing.T) {

}

func Test_newDynamodbKV(t *testing.T) {
_, err := newDynamodbKV(Config{Region: "us-west-2", TableName: "TEST"}, util_log.Logger)

require.NoError(t, err)
}

func Test_TTL(t *testing.T) {
ddbClientMock := &mockDynamodb{
putItem: func(input *dynamodb.PutItemInput) *dynamodb.PutItemOutput {
Expand Down

0 comments on commit 327792f

Please sign in to comment.