Skip to content

Commit bbf6337

Browse files
fix: don't set AWS profile when role chaining (#841)
Fixes #555 This is a crude attempt to the fix the issue by overwritting the profile name when the chain flag is passed. This is set at the end, right before returning the values to the shell, the only functionality difference should be that that the `AWS_PROFILE` environment variable will not be set when the `--chain` flag is passed.
1 parent 3e13a79 commit bbf6337

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/assume/assume.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,12 @@ func AssumeCommand(c *cli.Context) error {
519519
return nil
520520
}
521521

522+
// When using the `--chain` flag, the profile does not exist because it is an ARN we are assuming, not a profile generated by granted.
523+
// Since the profile does not exist, the awscli will error due to it attempting to use a non-existent profile.
524+
if assumeFlags.String("chain") != "" {
525+
profile.Name = "None"
526+
}
527+
522528
output := PrepareStringsForShellScript([]string{creds.AccessKeyID, creds.SecretAccessKey, creds.SessionToken, profile.Name, region, sessionExpiration, "false", "", "", "", "", ""})
523529
fmt.Printf("GrantedAssume %s %s %s %s %s %s %s %s %s %s %s %s", output...)
524530
}

0 commit comments

Comments
 (0)