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.
This commit is contained in:
Martin Atkins 2015-05-10 01:52:40 -07:00
parent 8af27bfb95
commit 5c30573a63
1 changed files with 11 additions and 8 deletions

View File

@ -106,6 +106,16 @@ func (c *Config) Client() (interface{}, error) {
MaxRetries: aws.Int(c.MaxRetries), MaxRetries: aws.Int(c.MaxRetries),
Endpoint: aws.String(c.DynamoDBEndpoint), 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") log.Println("[INFO] Initializing DynamoDB connection")
client.dynamodbconn = dynamodb.New(awsDynamoDBConfig) client.dynamodbconn = dynamodb.New(awsDynamoDBConfig)
@ -145,15 +155,8 @@ func (c *Config) Client() (interface{}, error) {
log.Println("[INFO] Initializing EFS Connection") log.Println("[INFO] Initializing EFS Connection")
client.efsconn = efs.New(awsConfig) 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") log.Println("[INFO] Initializing Route 53 connection")
client.r53conn = route53.New(&aws.Config{ client.r53conn = route53.New(usEast1AwsConfig)
Credentials: creds,
Region: aws.String("us-east-1"),
MaxRetries: aws.Int(c.MaxRetries),
})
log.Println("[INFO] Initializing Elasticache Connection") log.Println("[INFO] Initializing Elasticache Connection")
client.elasticacheconn = elasticache.New(awsConfig) client.elasticacheconn = elasticache.New(awsConfig)