A developer is testing an application locally that uses the AWS SDK for JavaScript. The developer wants to ensure the SDK uses the correct IAM permissions. The following configurations exist on the developer's workstation:
* The environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set to valid credentials for Developer A.
* The shared credentials file (~/.aws/credentials) contains a [default] profile for Developer B and a [testing] profile for Developer C.
* The environment variable AWS_PROFILE is set to testing.
The SDK client is initialized in the code without any custom credential configuration arguments. Which credentials will the AWS SDK use when making API calls?
- AThe credentials for Developer C, because the AWS_PROFILE environment variable overrides other environment variables to load the specific profile configuration.
- The credentials for Developer A, because environment variables have higher precedence in the SDK default credential provider chain than the shared credentials file.Answer
- CThe credentials for Developer B, because the default profile in the shared credentials file is always resolved before environment variables are evaluated.
- DThe credentials retrieved from AWS Systems Manager Parameter Store under the name specified by the AWS_PROFILE environment variable.
Answer
The credentials for Developer A, because environment variables have higher precedence in the SDK default credential provider chain than the shared credentials file.
The correct answer is the option stating that the credentials for Developer A are used. In the AWS SDK default credentials provider chain, individual environment variables (specifically AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) have higher precedence than profile configurations in the shared credentials file. As a result, the SDK resolves Developer A's credentials and terminates its search.
Step-by-Step Solution
Key Concept
AWS SDK Default Credentials Provider Chain Precedence