Skip to content

Commit

Permalink
pass nil function for auth/aws when no externalID supplied (#27858)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpcraig authored Jul 26, 2024
1 parent 5787fa2 commit 32fdae0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion builtin/credential/aws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strconv"
"time"

"github.com/aws/aws-sdk-go/aws/credentials"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
"github.com/aws/aws-sdk-go/aws/session"
Expand Down Expand Up @@ -130,7 +132,12 @@ func (b *backend) getClientConfig(ctx context.Context, s logical.Storage, region
if err != nil {
return nil, err
}
assumedCredentials := stscreds.NewCredentials(sess, stsRole, func(p *stscreds.AssumeRoleProvider) { p.ExternalID = aws.String(externalID) })
var assumedCredentials *credentials.Credentials
if externalID != "" {
assumedCredentials = stscreds.NewCredentials(sess, stsRole, func(p *stscreds.AssumeRoleProvider) { p.ExternalID = aws.String(externalID) })
} else {
assumedCredentials = stscreds.NewCredentials(sess, stsRole)
}
// Test that we actually have permissions to assume the role
if _, err = assumedCredentials.Get(); err != nil {
return nil, err
Expand Down
3 changes: 3 additions & 0 deletions changelog/27858.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
auth/aws: fixes an issue where not supplying an external id was interpreted as an empty external id
```

0 comments on commit 32fdae0

Please sign in to comment.