ExitAWS Lambda: JSON test events1 / 7
Explanationassociate7 steps · 3 exercises

Match the event your handler reads

How to create JSON inputs that match the events a handler receives and replay them using Lambda console test events or AWS SAM local invocation.

A test event is the JSON input to your Lambda handler. Start with the event format for the service and integration that normally invoke it. The Lambda console has sample events for many integrations. Keep the structure and value types your handler expects, and replace sample values with test data. If the handler needs no input, use {}.

For example, if your API Gateway handler parses event.body as JSON, a test event can contain {"body":"{\"name\":\"Ada\"}"}. The outer JSON is the Lambda event; body is a string containing the request payload. Include any other event fields your handler reads. To test API Gateway itself, send an HTTP request to the API rather than pasting the Lambda event envelope into the request body.

Next up: Fill the blanks on what you just read.