A developer is deploying a new AWS Lambda function that must write log data to an Amazon DynamoDB table. To keep the code reusable across multiple environments (such as staging and production), the developer must avoid hardcoding the DynamoDB table name. Additionally, the Lambda function must be authorized to write data to the DynamoDB table. Which two configurations should the developer use to meet these requirements? (Select two.)
- Configure environment variables for the function to dynamically specify the DynamoDB table name.Cevap
- Assign an IAM execution role to the Lambda function that contains permissions to write to the DynamoDB table.Cevap
- CStore the DynamoDB table name and AWS access keys directly within the function's code initialization.
- DAttach an IAM trust policy to the Lambda function that permits the DynamoDB service to assume the function's role.
- EDeploy the Lambda function inside a private subnet and configure a security group to block outbound internet traffic.
Cevap
To configure the function correctly, configure environment variables for the DynamoDB table name and assign an IAM execution role to the function with DynamoDB write permissions.
To dynamically change the target table name across different stages without redeploying code, the developer must use environment variables. To grant write permissions to the DynamoDB table, the developer must assign an IAM execution role to the Lambda function containing the correct policy permissions.
Adım Adım Çözüm
Anahtar Kavram
Lambda Environment Variables and IAM Execution Roles