Q8 — AWS DVA-C02 Ch.1
Question 8 of 100 | ← Chapter 1
A developer is creating a new REST API using Amazon API Gateway and AWS Lambda. Before deploying the API to production, the development team tests the API and validates responses for known use cases. The developer wants to test the REST API locally using API Gateway. Which AWS Serverless Application Model Command Line Interface (AWS SAM CLI) command meets these requirements?
- A. sam local invoke
- B. sam local generate-event
- C. sam local start-lambda
- D. sam local start-api ✓
Correct Answer: D. sam local start-api
Explanation
The 'sam local start-api' command in AWS SAM CLI launches a local instance of API Gateway and simulates AWS Lambda function invocations, enabling developers to test APIs end-to-end locally without deploying to production. Option A ('sam local invoke') invokes Lambda functions directly—not API Gateway. Option B ('sam local generate-event') generates sample Lambda events. Option C ('sam local start-lambda') is not a valid SAM CLI subcommand.