Skip to content

Commit 208fe9e

Browse files
committed
fix: no credentials provider in chain when not using a profile
Signed-off-by: gnuletik <[email protected]>
1 parent 790834e commit 208fe9e

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

provider/provider.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
awsstscreds "github.com/aws/aws-sdk-go/aws/credentials/stscreds"
2020
awssession "github.com/aws/aws-sdk-go/aws/session"
2121
awssigv4 "github.com/aws/aws-sdk-go/aws/signer/v4"
22-
awssts "github.com/aws/aws-sdk-go/service/sts"
2322
"github.com/deoxxa/aws_signing_client"
2423
"github.com/hashicorp/go-hclog"
2524
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -433,17 +432,12 @@ func assumeRoleCredentials(region, roleARN, roleExternalID, profile string, endp
433432
}
434433

435434
sess := awssession.Must(awssession.NewSessionWithOptions(sessOpts))
436-
stsClient := awssts.New(sess)
437-
assumeRoleProvider := &awsstscreds.AssumeRoleProvider{
438-
Client: stsClient,
439-
RoleARN: roleARN,
440-
}
441-
442-
if roleExternalID != "" {
443-
assumeRoleProvider.ExternalID = aws.String(roleExternalID)
444-
}
445435

446-
return awscredentials.NewChainCredentials([]awscredentials.Provider{assumeRoleProvider})
436+
return awsstscreds.NewCredentials(sess, roleARN, func(p *awsstscreds.AssumeRoleProvider) {
437+
if roleExternalID != "" {
438+
p.ExternalID = aws.String(roleExternalID)
439+
}
440+
})
447441
}
448442

449443
func awsSessionOptions(region string, endpoint string) awssession.Options {

0 commit comments

Comments
 (0)