-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
aws/session: Fix SDK AWS_PROFILE and static environment credential behavior #2694
Conversation
3775d3c
to
8cf79f8
Compare
@@ -5,3 +5,6 @@ | |||
### SDK Enhancements | |||
|
|||
### SDK Bugs | |||
* `aws/session`: Fix SDK AWS_PROFILE and static environment credential behavior () | |||
* Fixes the SDK's behavior when determining the source of credentials to load. Previously the SDK would ignore the AWS_PROFILE environment, if static environment credentials were also specified. |
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.
Should this be a SDK bug or an Enhancement, as it would be a minor release?
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.
Bug in this case, because it was incorrect, unexpected, behavior in the SDK.
…havior Fixes the SDK's behavior when determining the source of credentials to load. Previously the SDK would ignore the AWS_PROFILE environment, if static environment credentials were also specified. If both AWS_PROFILE and static environment credentials are defined, the SDK will load any credentials from the shared config/credentials file for the AWS_PROFILE first. Only if there are no credentials defined in the shared config/credentials file will the SDK use the static environment credentials instead.
8cf79f8
to
93720c6
Compare
@jasdel The "wrong" behavior is how the CLI works, and it seems like this change makes the SDK and the CLI have different assumptions on env precedence. Am I misunderstanding something in how credential resolution works? I have these (bad) keys in my default profile:
Then with no env vars set, it fails as expected:
Then set valid
Then I set
Would that still happen given this change? |
Hi @007 thanks for reaching out to us. I've verified the difference in behavior you mentioned between the SDK and CLI. It looks like the SDK and CLI differ in behavior with regards to the This will use the environment credentials, ignoring the credentials in AWS_ACCESS_KEY_ID=<key> \
AWS_SECRET_ACCESS_KEY=<secret> \
AWS_PROFILE=myProfile \
aws sts get-caller-identity Specifying the profile as a CLI's input arguments will use the AWS_ACCESS_KEY_ID=<key> \
AWS_SECRET_ACCESS_KEY=<secret> \
aws --profile profileToUse sts get-caller-identity |
It looks like the SDK's behavior with regard to the CLI is a little bit more complex than initially seemed. The CLI has an additional parameter to specify the profile separate from the I'm investigating how this should best be represented in the SDK. The AWS SDK for Go does allow a profile to be specified in code when creating a sess, err := session.NewSessionWithOptions(session.Options{
Profile: "myProfileToUse",
}) |
I created #2727 to track this bug, and fix. |
I think that behavior is correct, so order of resolution goes:
|
Sorry but is the `AWS_DEFAULT_PROFILE´ the proper name of the variable that controls the profiles? Using it a lot with the actual aws cli and boto3 |
Fixes the SDK's behavior when determining the source of credentials to
load. Previously the SDK would ignore the AWS_PROFILE environment, if
static environment credentials were also specified.
If both AWS_PROFILE and static environment credentials are defined, the
SDK will load any credentials from the shared config/credentials file
for the AWS_PROFILE first. Only if there are no credentials defined in
the shared config/credentials file will the SDK use the static
environment credentials instead.