From 3a2a7b60808828db98ea8352093044c52d51b87c Mon Sep 17 00:00:00 2001 From: mwas Date: Tue, 26 Nov 2019 13:07:44 +0300 Subject: [PATCH 1/2] adding support for overriding dynamo db endpoint --- backends/dynamodb/client.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backends/dynamodb/client.go b/backends/dynamodb/client.go index 9509d2d52..90d0400fc 100644 --- a/backends/dynamodb/client.go +++ b/backends/dynamodb/client.go @@ -21,9 +21,18 @@ type Client struct { // It returns an error if the connection cannot be made or the table does not exist. func NewDynamoDBClient(table string) (*Client, error) { var c *aws.Config + + var endpoint = "" if os.Getenv("DYNAMODB_LOCAL") != "" { log.Debug("DYNAMODB_LOCAL is set") - endpoint := "http://localhost:8000" + endpoint = "http://localhost:8000" + } else if os.Getenv("DYNAMODB_ENDPOINT") != "" { + log.Debug("DYNAMODB_ENDPOINT is set") + endpoint = os.Getenv("DYNAMODB_ENDPOINT") + } + + if endpoint != "" { + log.Debug("dynamodb endpoint: %s", endpoint) c = &aws.Config{ Endpoint: &endpoint, } From 056a54682a8ad13d675d5ce7abc59975eec76d4e Mon Sep 17 00:00:00 2001 From: mwas Date: Thu, 28 Nov 2019 15:49:02 +0300 Subject: [PATCH 2/2] fixing dynamodb endpoint --- backends/dynamodb/client.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backends/dynamodb/client.go b/backends/dynamodb/client.go index 90d0400fc..316e0d0a6 100644 --- a/backends/dynamodb/client.go +++ b/backends/dynamodb/client.go @@ -26,9 +26,10 @@ func NewDynamoDBClient(table string) (*Client, error) { if os.Getenv("DYNAMODB_LOCAL") != "" { log.Debug("DYNAMODB_LOCAL is set") endpoint = "http://localhost:8000" - } else if os.Getenv("DYNAMODB_ENDPOINT") != "" { - log.Debug("DYNAMODB_ENDPOINT is set") - endpoint = os.Getenv("DYNAMODB_ENDPOINT") + } + if os.Getenv("DYNAMODB_LOCAL_ENDPOINT") != "" { + log.Debug("DYNAMODB_LOCAL_ENDPOINT is set") + endpoint = os.Getenv("DYNAMODB_LOCAL_ENDPOINT") } if endpoint != "" {