Which AWS Serverless Application Model Command Line Interface (AWS SAM CLI) subcommand will meet these requirements?
Sam local invoke
Sam local generate-event
Sam local start-lambda
Sam local start-api
Explanations:
sam local invokeis used to invoke a specific Lambda function locally with an event payload. It is not meant for testing an API Gateway endpoint.
sam local generate-eventis used to generate sample event payloads for various AWS services, which can be useful for testing, but it does not start a local API Gateway.
sam local start-lambdastarts a local Lambda endpoint for invoking Lambda functions, but it does not start an API Gateway to expose HTTP endpoints for testing.
sam local start-apiis the correct command to run a local API Gateway that allows the developer to test the REST API endpoints defined in the SAM template. This command serves the API locally and simulates API Gateway behavior.