Question

Difficulty: EasyAWS SDKs and Credential Management

A developer is writing an AWS Lambda function that needs to write data to an Amazon DynamoDB table using the AWS SDK. How should the developer configure the AWS SDK client in the function code to authenticate securely with the database?

  1. Initialize the SDK client with default settings, allowing the default credential provider chain to automatically retrieve temporary credentials from the Lambda execution role.Answer
  2. B
    Hardcode the AWS Access Key ID and Secret Access Key of a highly privileged IAM user directly inside the SDK client constructor code.
  3. C
    Store the credential keys in AWS Systems Manager Parameter Store as a plain text parameter, even though the credentials require automatic 30-day rotation.
  4. D
    Modify the IAM execution role's permissions policy to establish the trust relationship that permits the AWS Lambda service to assume the role.

Answer

Initialize the SDK client with default settings, allowing the default credential provider chain to automatically retrieve temporary credentials from the Lambda execution role.
The correct option is correct because when running code inside AWS Lambda, the service automatically injects temporary credentials from the function's execution role into the environment. The AWS SDK, when initialized without custom configuration, uses the default credential provider chain to automatically find and use these environment variables.

Step-by-Step Solution

1
Identify the environment context in which the AWS SDK is running.
The SDK is running within an AWS Lambda function execution environment.
Understanding where the SDK runs determines how the credential provider chain resolves security credentials.
2
Determine how AWS Lambda manages permissions and credentials for execution.
Lambda uses an IAM execution role and automatically injects temporary credentials into the environment variables.
These environment variables are standard inputs for the AWS SDK credential resolution.
3
Evaluate the initialization method of the AWS SDK client.
Initializing the client with default parameters automatically triggers the default credential provider chain, which checks environment variables first.
This is the most secure and simplest approach, as it uses short-term credentials and requires zero manual configuration or hardcoding.

Key Concept

AWS SDK default credential provider chain and Lambda execution roles
Estimated Time:45s
Rate this question