From 5c30573a63d14531fb560e140ceadac61777db19 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Sun, 10 May 2015 01:52:40 -0700 Subject: [PATCH] AWS config forced to us-east-1 in variable, not inline. There are several AWS services that are global in scope and thus need to be accessed via the us-east-1 endpoints, so we'll make the us-east-1 variant of the config available as a variable we can reuse between multiple clients as we add support for new services. --- builtin/providers/aws/config.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/builtin/providers/aws/config.go b/builtin/providers/aws/config.go index f462810fc1..5f1f18a8c5 100644 --- a/builtin/providers/aws/config.go +++ b/builtin/providers/aws/config.go @@ -106,6 +106,16 @@ func (c *Config) Client() (interface{}, error) { MaxRetries: aws.Int(c.MaxRetries), Endpoint: aws.String(c.DynamoDBEndpoint), } + // Some services exist only in us-east-1, e.g. because they manage + // resources that can span across multiple regions, or because + // signature format v4 requires region to be us-east-1 for global + // endpoints: + // http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html + usEast1AwsConfig := &aws.Config{ + Credentials: creds, + Region: aws.String("us-east-1"), + MaxRetries: aws.Int(c.MaxRetries), + } log.Println("[INFO] Initializing DynamoDB connection") client.dynamodbconn = dynamodb.New(awsDynamoDBConfig) @@ -145,15 +155,8 @@ func (c *Config) Client() (interface{}, error) { log.Println("[INFO] Initializing EFS Connection") client.efsconn = efs.New(awsConfig) - // aws-sdk-go uses v4 for signing requests, which requires all global - // endpoints to use 'us-east-1'. - // See http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html log.Println("[INFO] Initializing Route 53 connection") - client.r53conn = route53.New(&aws.Config{ - Credentials: creds, - Region: aws.String("us-east-1"), - MaxRetries: aws.Int(c.MaxRetries), - }) + client.r53conn = route53.New(usEast1AwsConfig) log.Println("[INFO] Initializing Elasticache Connection") client.elasticacheconn = elasticache.New(awsConfig)