Skip to content
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

Merged
merged 5 commits into from
Feb 29, 2024

Conversation

danielrbradley
Copy link
Member

@danielrbradley danielrbradley commented Feb 28, 2024

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

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.
@danielrbradley danielrbradley self-assigned this Feb 28, 2024
@danielrbradley danielrbradley added the impact/no-changelog-required This issue doesn't require a CHANGELOG update label Feb 28, 2024
Copy link
Contributor

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Copy link

codecov bot commented Feb 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 22.71%. Comparing base (58c782c) to head (a870731).

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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@mjeffryes mjeffryes left a 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

@mjeffryes mjeffryes added impact/changelog and removed impact/no-changelog-required This issue doesn't require a CHANGELOG update labels Feb 28, 2024
@danielrbradley danielrbradley enabled auto-merge (squash) February 29, 2024 09:05
@danielrbradley danielrbradley enabled auto-merge (squash) February 29, 2024 09:17
@danielrbradley danielrbradley merged commit 550eb8c into master Feb 29, 2024
17 checks passed
@danielrbradley danielrbradley deleted the 1191-prefer-config-profile-over-env branch February 29, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Environment variables take precedence over explicit configuration
4 participants