A developer is troubleshooting an application locally on their workstation. They are running a Node.js application that uses the AWS SDK for JavaScript (v3) to upload objects to an Amazon S3 bucket.
The developer has configured a profile named `staging` in their local `~/.aws/credentials` file:
ini
[staging]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
They also set the following environment variables in their terminal session:
bash
export AWS_PROFILE=staging
export AWS_ACCESS_KEY_ID=AKIAIADSTESTINGEXAMPLE
export AWS_SECRET_ACCESS_KEY=mockKeyStagingExampleKey
When running the application, the developer receives access denied errors because the SDK attempts to authenticate using the `AKIAIADSTESTINGEXAMPLE` credentials (which are invalid) rather than the credentials specified in the `staging` profile.
Which action should the developer take to ensure the SDK uses the `staging` profile credentials?
- ASet the AWS_SDK_LOAD_CONFIG environment variable to true.
- BAdd aws_profile = staging inside the default section of the ~/.aws/config file.
- Unset the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.Cevap
- DPass the profile name directly to the client constructor by initializing the S3 client as new S3Client({ profile: 'staging' }).