Question #1102
A team is developing an e-commerce platform using AWS SAM. They want to test Lambda functions locally using event payloads that precisely mirror those generated by AWS services. The goal is to minimize setup time and manual effort.
Which approach achieves this with the LEAST development overhead?
Develop custom test events and share them across the team for local testing.
Manually create test events and store them locally, then reference them with SAM CLI.
Store manually created events in S3 and reference them via SAM CLI.
Use SAM CLI's generate-event command to produce test payloads.
Explanation
The correct answer is D because the SAM CLI's generate-event command automatically generates sample event payloads matching those produced by AWS services (e.g., S3, API Gateway). This eliminates the need to manually create or store test events (as in Options A, B, and C), reducing development overhead.
- Option A requires custom event creation and sharing, which is time-consuming and error-prone.
- Option B involves manual event creation and local storage, adding maintenance effort.
- Option C introduces unnecessary complexity by storing events in S3.
- Option D leverages built-in SAM CLI functionality, ensuring accuracy and efficiency.
Key Points: SAM CLI's generate-event provides ready-to-use, service-specific event templates, ensuring consistency with AWS services while minimizing manual work.
Answer
The correct answer is: D