Question

Difficulty: EasyTroubleshooting Local Development and AWS Credentials

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.)

  1. 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
  2. Set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables in the local shell session where the application is executed.Answer
  3. C
    Hardcode the AWS Access Key ID and Secret Access Key directly into the AWS SDK client constructor in the application code.
  4. D
    Modify 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.
  5. E
    Store 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

1
Identify that the AWS SDK requires valid credentials (access key ID and secret access key) to authenticate local API requests.
The application fails because no credentials are provided to the default credential provider chain.
By default, the SDK checks environment variables and local configuration files to locate credentials.
2
Apply a secure local credentials configuration method by either writing the credentials to the default shared AWS credentials file or exporting them as environment variables.
The SDK successfully loads the credentials automatically without hardcoding them in the source code.
Environment variables and the credentials file are high-priority locations checked by the default credential provider chain.

Key Concept

AWS SDK Default Credential Provider Chain and Local Authentication
Rate this question