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?
- Initialize the SDK client with default settings, allowing the default credential provider chain to automatically retrieve temporary credentials from the Lambda execution role.Cevap
- BHardcode the AWS Access Key ID and Secret Access Key of a highly privileged IAM user directly inside the SDK client constructor code.
- CStore the credential keys in AWS Systems Manager Parameter Store as a plain text parameter, even though the credentials require automatic 30-day rotation.
- DModify the IAM execution role's permissions policy to establish the trust relationship that permits the AWS Lambda service to assume the role.
Cevap
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.
Adım Adım Çözüm
Anahtar Kavram
AWS SDK default credential provider chain and Lambda execution roles
Tahmini Süre:45s