-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix precedence of credential sources #1378
Conversation
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. We don't currently have any good facility to test the various difference configuration variations. 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.
Does the PR have any schema changes?Looking good! No breaking changes found. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1378 +/- ##
=======================================
Coverage 22.71% 22.71%
=======================================
Files 25 25
Lines 4226 4226
=======================================
Hits 960 960
Misses 3105 3105
Partials 161 161 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like the correct behavior to me, but I it is a backwards incompatible change, so we should probably at least make a note of it in the CHANGELOG
…1191-prefer-config-profile-over-env
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