DVA-C02 Question 237
Single answerYou are developing a serverless application using AWS Lambda, and you want to test the application in a development environment. The application stores data in an Amazon DynamoDB table. To test the application without incurring high costs and to ensure that your development environment closely mimics production, what is the best practice?
- A
Use the AWS Lambda console to run test events and point to the production DynamoDB table.
- B
Create a separate DynamoDB table for development and configure your Lambda function to use the development table.
- C
Enable DynamoDB Streams on your production table and use the stream to test your application in the development environment.
- D
Use the AWS SAM CLI to create a local development environment that includes a local version of DynamoDB.
Show answer and explanation
Correct answer: B
Explanation
The best practice for testing in a development environment is to isolate the environment from production to avoid impacting production data and incurring unexpected costs. Using a separate DynamoDB table for development ensures that testing is safe and does not interfere with live data while maintaining a close resemblance to the production setup.
- A. Incorrect.
This option is not a best practice as it involves using production resources in a development environment, which can lead to unintentional data modifications and higher costs.
- B. Correct.
This is the correct answer. Using a separate DynamoDB table for development ensures that production data is not affected, while allowing you to test in an environment that closely resembles production.
- C. Incorrect.
Using DynamoDB Streams in this way is not suitable for testing in a development environment because it introduces unnecessary complexity and still interacts with production resources.
- D. Incorrect.
While the AWS SAM CLI can be used for local testing, it is not ideal for testing interactions with actual DynamoDB tables. It is better suited for testing Lambda functions locally without involving AWS services directly.