AWS Certified Developer – Associate (DVA-C02) — Question 527
A company is using the AWS Serverless Application Model (AWS SAM) to develop a social media application. A developer needs a quick way to test AWS Lambda functions locally by using test event payloads. The developer needs the structure of these test event payloads to match the actual events that AWS services create.
Which solution will meet these requirements with the LEAST development effort?
Answer options
- A. Create shareable test Lambda events. Use these test Lambda events for local testing.
- B. Store manually created test event payloads locally. Use the sam local invoke command with the file path to the payloads.
- C. Store manually created test event payloads in an Amazon S3 bucket. Use the sam local invoke command with the S3 path to the payloads.
- D. Use the sam local generate-event command to create test payloads for local testing.
Correct answer: D
Explanation
The sam local generate-event command is the most efficient way to generate realistic mock payloads for various AWS services without manual creation, satisfying the requirement for least development effort. Options B and C require manual payload creation, which increases effort and risk of structural mismatch. Option A relies on shareable test events but still requires manual creation or setup compared to the built-in CLI generator.