Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix precedence of credential sources (#1378)
When both environment variables such as `AWS_ACCESS_KEY_ID` are present, and a profile is set explicitly in provider configuration, we will now choose the explict provider configuration. Don't load AWS environment variables ourselves as this is implemented in AWS's LoadDefaultConfig method already where it has the correct preference to use the named profile over any environment variables. This precidence is defined here: https://github.com/aws/aws-sdk-go-v2/blob/58cf6509525a12d64fd826da883bfdbacbd2f00e/config/resolve_credentials.go#L102-L134 When we were parsing the access key environment variables ourselves, it appeared to AWS's library that these were not just in the environment, but specified manually by us alongside the profile. When the profile is defined alongside an explicit access key, the profile is ignored. However, if only the profile is specified by the user, but access keys are available ambiently via the environment, the profile will be used instead. We don't currently have any good facility to test the various difference configuration variations so have tested this manually by altering local configuration. We might also be able to remove the custom checking for AWS_REGION, AWS_DEFAULT_REGION and AWS_SHARED_CREDENTIALS_FILE for the same reason, but this will require further manual testing. Fixes #1191 --------- Co-authored-by: Ramon Quitales <ramon@pulumi.com>
- Loading branch information