AWS_PROFILE environment variable overrides session credentials #4121
Labels
bug
This issue is a confirmed bug.
closed-for-staleness
credentials
p2
This is a standard priority issue
response-requested
Waiting on additional information or feedback.
Describe the bug
When setting up a client or session if I pass in an aws_access_key_id, aws_secret_access_key, and region it will first attempt to make a connection using the environment variable set in AWS_PROFILE.
If this variable is set incorrectly, as in there is no matching profile, a ProfileNotFound exception is thrown.
This is problematic as I've had a user with this variable set and it took a great deal of time to track down why my software wouldn't work on their machine. Whether this is used for the actual connection to the service is irrelevant as this environment variable should have nothing to do with my connection if I am manually passing in my own credentials.
Expected Behavior
If credentials are passed into the constructor for either boto3.session.Session or boto3.client the environment variable AWS_PROFILE should not utilized and no exception should be raised.
Current Behavior
If the machine has an environment variable set for AWS_PROFILE incorrectly an exception is raised by botocore/session.py regardless of whether correct credentials are passed in via the constructor.
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
SDK version used
1.34.43
Environment details (OS name and version, etc.)
Mac OS Sonoma 14.4.1
The text was updated successfully, but these errors were encountered: