Skip to content

Commit a5d9a15

Browse files
secrets/aws: fix a bug where environment and shared credential providers were overriding the WIF configuration (#29982)
1 parent 629b04c commit a5d9a15

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

builtin/logical/aws/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func (b *backend) getRootConfigs(ctx context.Context, s logical.Storage, clientT
9797
}
9898
}
9999

100+
opts := make([]awsutil.Option, 0)
100101
if config.IdentityTokenAudience != "" {
101102
ns, err := namespace.FromContext(ctx)
102103
if err != nil {
@@ -115,6 +116,10 @@ func (b *backend) getRootConfigs(ctx context.Context, s logical.Storage, clientT
115116
credsConfig.RoleSessionName = fmt.Sprintf("vault-aws-secrets-%s", sessionSuffix)
116117
credsConfig.WebIdentityTokenFetcher = fetcher
117118
credsConfig.RoleARN = config.RoleARN
119+
120+
// explicitly disable environment and shared credential providers when using Web Identity Token Fetcher
121+
// enables WIF usage in environments that may use AWS Profiles or environment variables for other use-cases
122+
opts = append(opts, awsutil.WithEnvironmentCredentials(false), awsutil.WithSharedCredentials(false))
118123
}
119124

120125
if len(regions) == 0 {
@@ -132,7 +137,7 @@ func (b *backend) getRootConfigs(ctx context.Context, s logical.Storage, clientT
132137
} else {
133138
credsConfig.Region = fallbackRegion
134139
}
135-
creds, err := credsConfig.GenerateCredentialChain()
140+
creds, err := credsConfig.GenerateCredentialChain(opts...)
136141
if err != nil {
137142
return nil, err
138143
}

changelog/29982.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
secrets/aws: fix a bug where environment and shared credential providers were overriding the WIF configuration
3+
```

0 commit comments

Comments
 (0)