A developer is troubleshooting a Python application on a local development workstation. The application uses the AWS SDK for Python (Boto3) to interact with AWS resources.
The developer has configured two profiles in the local `~/.aws/credentials` file: a `default` profile and a `custom-dev` profile.
To test the application locally, the developer runs the following commands in the terminal:
bash
export AWS_PROFILE=custom-dev
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
When the developer runs the application, they notice that the SDK uses the IAM credentials from the environment variables rather than the configuration defined for `custom-dev` in the credentials file.
Why does the AWS SDK execute the requests using the environment variable credentials instead of the `custom-dev` profile?
- The AWS SDK credential provider chain evaluates environment variables for explicit access keys before loading credentials from the shared credentials file.Answer
- BThe AWS_PROFILE environment variable is only recognized by the AWS CLI, whereas the AWS SDK ignores it and defaults to environment variables.
- CThe shared credentials file is only read if the environment variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not set, but the configuration requires setting AWS_SDK_LOAD_CONFIG=true to prioritize the credentials file.
- DThe AWS SDK requires the trust policy of the IAM role in the custom-dev profile to explicitly allow local execution before it can override environment variables.