Skip to content

Commit

Permalink
common: Fix error when loading assume role policy
Browse files Browse the repository at this point in the history
  • Loading branch information
hamstah committed Aug 18, 2019
1 parent d6dc7a5 commit 7342de0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions common/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ func AssumeRoleConfig(sessionFlags *SessionFlags, sess *session.Session) *aws.Co
}

if *sessionFlags.RolePolicy != "" {
policyBytes, err := ioutil.ReadFile(*sessionFlags.RolePolicy)
if err != nil {
if !os.IsNotExist(err) {
if (*sessionFlags.RolePolicy)[0] != '{' {
policyBytes, err := ioutil.ReadFile(*sessionFlags.RolePolicy)
if err != nil {
panic(errors.Wrap(err, "failed to load role policy"))
}
p.Policy = sessionFlags.RolePolicy
} else {
p.Policy = aws.String(string(policyBytes))
} else {
p.Policy = sessionFlags.RolePolicy
}
}

Expand Down

0 comments on commit 7342de0

Please sign in to comment.