A developer is deploying a Go-based microservice to AWS Lambda. The microservice uses the AWS SDK for Go to retrieve items from an Amazon DynamoDB table.
Which of the following is the most secure and standard way to configure the AWS SDK client to authenticate requests?
- Initialize the SDK client using the default configuration settings so it automatically inherits permissions from the Lambda function's execution role.Cevap
- BPass a hardcoded AWS Access Key ID and Secret Access Key into the SDK client configuration constructor.
- CStore long-lived IAM User credentials in Systems Manager Parameter Store as a plain text string and fetch them at client initialization.
- DUpdate the trust policy of the Lambda execution role to allow DynamoDB to assume the role instead of attaching a permissions policy.
Cevap
Initialize the SDK client using the default configuration settings so it automatically inherits permissions from the Lambda function's execution role.
The correct option is to initialize the SDK client using default configuration settings. When running inside AWS Lambda, the AWS SDK automatically utilizes the Default Credential Provider Chain to retrieve the temporary credentials associated with the function's execution role from the environment. This is the most secure approach because it avoids hardcoding secrets and relies on temporary, automatically rotated credentials.
Adım Adım Çözüm
Anahtar Kavram
AWS SDK Default Credential Provider Chain and Lambda Execution Roles