A developer is troubleshooting a local Node.js application running inside a Docker container. The application uses the AWS SDK for JavaScript (v3) to read data from an Amazon DynamoDB table. The application is configured to run under a non-root user named `node` with a home directory at `/home/node`. The developer wants the containerized application to use the AWS credentials defined in the `dev-profile` profile from the host machine's `~/.aws/credentials` file. Which combination of actions will allow the application in the container to successfully authenticate using the `dev-profile` credentials? (Select TWO.)
- Mount the host machine's ~/.aws directory to /home/node/.aws inside the container.Cevap
- Set the AWS_PROFILE environment variable to dev-profile inside the container.Cevap
- CCopy the host machine's ~/.aws/credentials file into the container image using a COPY instruction in the Dockerfile.
- DMount the host machine's ~/.aws directory to /root/.aws inside the container.
- EInitialize the DynamoDB client in the application code by hardcoding the AWS access keys.
Cevap
Mount the host machine's ~/.aws directory to /home/node/.aws inside the container and set the AWS_PROFILE environment variable to dev-profile inside the container.
The correct combination requires mounting the host's ~/.aws directory to the container user's home directory (/home/node/.aws) so that the AWS SDK running as the 'node' user can read the credentials file. Additionally, setting the AWS_PROFILE environment variable to dev-profile ensures that the SDK uses the specified profile instead of the default profile.
Adım Adım Çözüm
Anahtar Kavram
Configuring AWS credentials in local containerized development environments for non-root users.