Skip to content

Commit

Permalink
Merge pull request 99designs#257 from frezbo/feature/rotate-region-fix
Browse files Browse the repository at this point in the history
Updating session creator to always use the region specified
  • Loading branch information
lox authored May 16, 2018
2 parents e18d4e6 + 86a7b6c commit ae56f73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions vault/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ func (p *VaultProvider) assumeRole(creds credentials.Value, roleArn string) (sts
type KeyringProvider struct {
Keyring keyring.Keyring
Profile string
Region string
}

func (p *KeyringProvider) IsExpired() bool {
Expand Down
7 changes: 4 additions & 3 deletions vault/rotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ func (r *Rotator) Rotate(profile string) error {
provider := &KeyringProvider{
Keyring: r.Keyring,
Profile: source.Name,
Region: source.Region,
}

oldMasterCreds, err := provider.Retrieve()
if err != nil {
return err
}

oldSess := session.New(&aws.Config{
oldSess := session.New(&aws.Config{Region: aws.String(provider.Region),
Credentials: credentials.NewCredentials(&credentials.StaticProvider{Value: oldMasterCreds}),
})

Expand Down Expand Up @@ -84,7 +85,7 @@ func (r *Rotator) Rotate(profile string) error {
iamUserName = aws.String(currentUserName)
}

oldSessionClient := iam.New(session.New(&aws.Config{
oldSessionClient := iam.New(session.New(&aws.Config{Region: aws.String(provider.Region),
Credentials: credentials.NewCredentials(&credentials.StaticProvider{Value: oldSessionVal}),
}))

Expand Down Expand Up @@ -131,7 +132,7 @@ func (r *Rotator) Rotate(profile string) error {
return err
}

newClient := iam.New(session.New(&aws.Config{
newClient := iam.New(session.New(&aws.Config{Region: aws.String(provider.Region),
Credentials: credentials.NewCredentials(&credentials.StaticProvider{Value: newVal}),
}))

Expand Down

0 comments on commit ae56f73

Please sign in to comment.