Skip to content

Commit

Permalink
Handle errors from getRootConfig on aws logical backend (#3294)
Browse files Browse the repository at this point in the history
  • Loading branch information
calvn authored and jefferai committed Sep 8, 2017
1 parent 38be344 commit 8a65b17
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions builtin/logical/aws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,25 @@ func getRootConfig(s logical.Storage) (*aws.Config, error) {
}

func clientIAM(s logical.Storage) (*iam.IAM, error) {
awsConfig, _ := getRootConfig(s)
return iam.New(session.New(awsConfig)), nil
awsConfig, err := getRootConfig(s)
if err != nil {
return nil, err
}
client := iam.New(session.New(awsConfig))
if client == nil {
return nil, fmt.Errorf("could not obtain iam client")
}
return client, nil
}

func clientSTS(s logical.Storage) (*sts.STS, error) {
awsConfig, _ := getRootConfig(s)
return sts.New(session.New(awsConfig)), nil
awsConfig, err := getRootConfig(s)
if err != nil {
return nil, err
}
client := sts.New(session.New(awsConfig))
if client == nil {
return nil, fmt.Errorf("could not obtain sts client")
}
return client, nil
}

0 comments on commit 8a65b17

Please sign in to comment.