Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
[Fix] Multi-region AWS configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
graham jenson committed Apr 8, 2019
1 parent 6d250e3 commit f9ac91e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions aws/aws.go
Expand Up @@ -52,11 +52,18 @@ func (c Clients) Config(
account_id *string,
role *string) *aws.Config {

config := aws.NewConfig().WithMaxRetries(10)

if region != nil {
config = config.WithRegion(*region)
}

// return no config for nil inputs
if account_id == nil || region == nil || role == nil {
return nil
if account_id == nil || role == nil {
return config
}

// Assume a role
arn := fmt.Sprintf(
"arn:aws:iam::%v:role/%v",
*account_id,
Expand All @@ -75,10 +82,7 @@ func (c Clients) Config(
creds := stscreds.NewCredentials(c.Session(), arn)

// new config
config := aws.NewConfig().
WithCredentials(creds).
WithRegion(*region).
WithMaxRetries(10)
config = config.WithCredentials(creds)

if c.configs == nil {
c.configs = map[string]*aws.Config{}
Expand Down

0 comments on commit f9ac91e

Please sign in to comment.