A developer has built a REST API using Amazon API Gateway and AWS Lambda and wants to enable local testing of the API using the AWS SAM CLI. Which AWS SAM CLI subcommand allows running the API locally for testing?
Choose an answer
Tap an option to check your answer.
Correct answer: sam local start-api.
Why this is the answer
The sam local start-api subcommand is specifically designed to emulate the API Gateway locally, allowing developers to test their REST APIs and Lambda functions without deploying them to AWS. It starts a local web server that mimics API Gateway's behavior, routing requests to the corresponding local Lambda functions defined in the SAM template. sam local invoke is used to invoke a single Lambda function locally, not an entire API. sam local generate-event creates sample event payloads for various AWS services, which is useful for testing individual Lambda functions but doesn't start an API. sam local start-lambda starts a local endpoint that emulates the AWS Lambda service, allowing other services (like a locally running application) to invoke local Lambda functions, but it doesn't provide the API Gateway emulation needed for a full API test.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed