DVA-C02 Question 77
Select 2You are developing a serverless application using AWS Lambda and Amazon DynamoDB. The application requires the ability to perform Create, Read, Update, and Delete (CRUD) operations on items in a DynamoDB table. Which of the following steps are necessary to ensure the Lambda function can perform these operations?
- A
Attach an IAM policy to the Lambda function's execution role that grants specific permissions to the DynamoDB table.
- B
Set up a VPC endpoint for DynamoDB to allow private communication between Lambda and DynamoDB.
- C
Ensure the Lambda function's execution role has the 'AmazonDynamoDBFullAccess' managed policy attached.
- D
Use the AWS SDK in the Lambda function to interact with the DynamoDB table.
- E
Enable DynamoDB Streams to capture data changes for the table.
Show answer and explanation
Correct answers: A, D
Explanation
To enable a Lambda function to perform CRUD operations on a DynamoDB table, the Lambda function's execution role must include an appropriate IAM policy granting the necessary permissions. Additionally, the AWS SDK must be used within the Lambda function to programmatically interact with the DynamoDB table. Other options, such as enabling DynamoDB Streams or setting up a VPC endpoint, are unrelated to the basic functionality required for CRUD operations in this scenario.
- A. Correct.
Correct. The Lambda function needs an IAM policy attached to its execution role that explicitly grants permissions for the necessary CRUD operations on the DynamoDB table.
- B. Incorrect.
Incorrect. A VPC endpoint for DynamoDB is not required unless the Lambda function is deployed inside a private VPC, which is not mentioned in the scenario.
- C. Incorrect.
Incorrect. While the 'AmazonDynamoDBFullAccess' policy would grant permissions, it is generally not recommended due to the principle of least privilege. Instead, a specific policy should be created for the required actions.
- D. Correct.
Correct. The AWS SDK is required to perform CRUD operations programmatically within the Lambda function. The SDK provides the necessary methods to interact with DynamoDB.
- E. Incorrect.
Incorrect. DynamoDB Streams is used to capture changes to the table, not for performing CRUD operations.