Jeff’s Note #
Unlike generic exam dumps, ADH analyzes this scenario through the lens of a Real-World Lead Developer.
For DVA-C02 candidates, the confusion often lies in distinguishing the AWS SAM CLI subcommands for local Lambda and API Gateway testing. In production, this is about knowing exactly which local command can replicate API Gateway behavior to invoke Lambda functions with HTTP events. Let’s drill down.
The Certification Drill (Simulated Question) #
Scenario #
NetStream Innovations is building a new RESTful API using Amazon API Gateway and AWS Lambda functions. During the development cycle, the engineering team has validated Lambda invocation for known inputs and outputs. Now, the lead developer wants to test the full REST API integration locally—simulating API Gateway’s HTTP interface to ensure the API behaves correctly—before deploying it into the cloud environment.
The Requirement: #
Which AWS SAM CLI subcommand should the developer use to start a local REST API endpoint for testing and simulating API Gateway calls?
The Options #
- A) sam local invoke
- B) sam local generate-event
- C) sam local start-lambda
- D) sam local start-api
Google adsense #
leave a comment:
Correct Answer #
D) sam local start-api
Quick Insight: The Developer Imperative #
- To fully simulate the HTTP API Gateway interface in a local environment,
sam local start-apispins up a local REST endpoint linked to Lambda handlers, allowing HTTP method invocation like GET, POST, PUT, etc.sam local invokeexecutes a Lambda function directly but requires you to manually supply event data — it does not simulate API Gateway HTTP requests.sam local generate-eventonly creates sample event JSON but does not invoke nor start any server.sam local start-lambdalaunches a local endpoint that waits for Lambda runtime invocation calls but does not simulate RESTful HTTP behavior through API Gateway.
Content Locked: The Expert Analysis #
You’ve identified the answer. But do you know the implementation details that separate a Junior from a Senior?
The Expert’s Analysis #
Correct Answer #
Option D - sam local start-api
The Winning Logic #
sam local start-apilaunches a local proxy server that mimics API Gateway’s RESTful interface. It reads your API definition in your SAM template, starts HTTP endpoints reflecting your API paths and methods, and routes requests to your Lambda functions as they would execute in the cloud.- This approach allows developers to perform full HTTP request testing locally — including headers, query parameters, and request bodies — without deploying to AWS. It’s the closest local behavior to an actual API Gateway + Lambda runtime.
The Trap (Distractor Analysis): #
-
Why not A - sam local invoke?
This command triggers Lambda functions by directly sending event JSON payloads. It lacks an HTTP interface and doesn’t simulate API Gateway behavior. Good for unit testing Lambda, but not API-level testing. -
Why not B - sam local generate-event?
This only creates sample event payloads (for example, an API Gateway event structure) but does not execute any code or start servers. -
Why not C - sam local start-lambda?
This runs a local endpoint that emulates the Lambda runtime API, useful for invoking Lambdas asynchronously or for integration with other tooling. However, it does not expose an HTTP REST API likestart-api.
The Technical Blueprint #
# Start local API Gateway simulation with SAM CLI
sam local start-api
# This command boots a Flask or Node.js based local HTTP server listening typically on port 3000.
# Example testing locally:
curl http://localhost:3000/myresource -X GET
The Comparative Analysis #
| Option | API Complexity | Performance | Use Case |
|---|---|---|---|
| A) sam local invoke | Low - direct function | Fast | Unit test Lambda with event JSON |
| B) sam local generate-event | None - generates events | N/A | Generate sample event payloads |
| C) sam local start-lambda | Medium - Lambda runtime | Moderate | Integrate with local Lambda runtime API |
| D) sam local start-api | High - full HTTP server | Moderate | Local API Gateway + Lambda REST API testing |
Real-World Application (Practitioner Insight) #
Exam Rule #
For the exam, always pick sam local start-api when you see testing REST APIs locally with API Gateway simulation.
Real World #
In real projects, we sometimes pair start-lambda with tools that invoke Lambda asynchronously or for step functions. But for actual REST HTTP API simulation, start-api is the command that matches the cloud experience.
(CTA) Stop Guessing, Start Mastering #
Disclaimer
This is a study note based on simulated scenarios for the AWS DVA-C02 exam.