AWS Certified Developer – Associate (DVA-C02) — Question 549

A developer is creating a new REST API by using Amazon API Gateway and AWS Lambda. The development team tests the API and validates responses for the known use cases before deploying the API to the production environment.

The developer wants to make the REST API available for testing by using API Gateway locally.

Which AWS Serverless Application Model Command Line Interface (AWS SAM CLI) subcommand will meet these requirements?

Answer options

Correct answer: D

Explanation

The `sam local start-api` command hosts a local HTTP server that emulates your Amazon API Gateway endpoints, allowing you to test your REST API locally. In contrast, `sam local invoke` only executes a single Lambda function once, and `sam local start-lambda` emulates the programmatic Lambda invocation API rather than an HTTP API Gateway. `sam local generate-event` is used to create mock event payloads for testing but does not run a local server.