Move CLIConfig instantiation inside of ProfileName check.

This commit is contained in:
Christopher Gerber 2016-02-02 08:36:36 -06:00
parent 883acb18fa
commit 7975c5e336
1 changed files with 5 additions and 6 deletions

View File

@ -29,12 +29,6 @@ type AccessConfig struct {
func (c *AccessConfig) Config() (*aws.Config, error) {
var creds *credentials.Credentials
profile := &CLIConfig{}
err := profile.Prepare(c.ProfileName)
if err != nil {
return nil, err
}
region, err := c.Region()
if err != nil {
return nil, err
@ -46,6 +40,11 @@ func (c *AccessConfig) Config() (*aws.Config, error) {
}
if c.ProfileName != "" {
profile := &CLIConfig{}
err := profile.Prepare(c.ProfileName)
if err != nil {
return nil, err
}
creds = c.assumeRoleCreds(config, profile)
} else {
creds = credentials.NewChainCredentials([]credentials.Provider{