Description
Documentation
- I've gone though the API reference
- I've checked AWS Forums and StackOverflow for answers
- I've searched for previous similar issues and didn't find any solution
Describe the bug
We are trying to specify a shared profile config as follows:
config.LoadDefaultConfig(context.Background(), config.WithSharedConfigProfile("some-profile"))
The docs state here: "If you specify credentials in environment variables, the SDK always uses those credentials, no matter which profile you specify." However, if you specify a shared profile, the SDK uses the credentials in the specified shared config profile rather than the env vars.
After a quick investigation it looks like the bug comes from the following case statement. Maybe fallthrough
was intended here.
Expected behavior
The SDK should use the credentials in the environment variables.
Current behavior
The SDK uses the credentials in the aws Config file.
Steps to Reproduce
repro.go:
import "github.com/aws/aws-sdk-go-v2/config"
cfg, err := config.LoadDefaultConfig(context.Background(), config.WithSharedConfigProfile("some-profile"))
if err != nil {
panic(err)
}
- Set credentials in AWS Config
- Run
AWS_ACCESS_KEY=XXXXXXX AWS_SECRET_ACCESS_KEY=XXXXXXX AWS_SESSION_TOKEN=XXXXXXXX go run repro.go
The credentials are set in the env vars, but the ones in the Config file are used.
Possible Solution
Fix the control flow here if the intended behaviour is to have the env vars to take precedence, or update the docs otherwise.
AWS Go SDK version used
1.1.6
Compiler and Version used
go version go1.17.3 darwin/amd64
Operating System and version
macOS Big Sur 11.6.2