A developer is running a local Node.js application that uses the AWS SDK to read from an Amazon S3 bucket. During local testing, the application fails to connect to AWS and throws a credential loading error. Which two actions should the developer take to resolve this issue securely? (Select TWO.)
- Configure the AWS Access Key ID and Secret Access Key in the shared AWS credentials file located at the default user profile path on the local machine.Answer
- Set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables in the local shell session where the application is executed.Answer
- CHardcode the AWS Access Key ID and Secret Access Key directly into the AWS SDK client constructor in the application code.
- DModify the IAM Role trust policy of the target S3 bucket to allow direct access from the public IP address of the local developer's workstation.
- EStore the credentials in an unencrypted plaintext parameter within AWS Systems Manager Parameter Store and retrieve them at application startup.
Answer
Configure the credentials in the shared AWS credentials file on the local machine, or set the access keys as environment variables in the local shell session.
The correct options are configuring the credentials in the shared AWS credentials file or setting the credentials as environment variables. The AWS SDK default credential provider chain automatically searches for environment variables first, followed by the shared credentials file. Both options are standard, secure ways to provide credentials to local applications without modifying the code.
Step-by-Step Solution
Key Concept
AWS SDK Default Credential Provider Chain and Local Authentication