Skill 3.2.3
Create application test events (for example, by using JSON payloads to test Lambda functions and API Gateway APIs).
Key Concepts
Each event source has its own event structure: an API Gateway proxy event contains the path, method, headers and body, an S3 event contains Records with bucket and key, and an SQS event contains Records with message bodies. sam local generate-event produces these templates, which you then edit and save alongside your tests.
Saved events can be used by sam local invoke -e, by unit tests, and as shareable test events in the Lambda console so the whole team uses the same payloads. Keeping them in the repository makes them part of the automated test suite.
Sample events can be generated with sam local generate-event and fed to functions locally, and the EventBridge console's sandbox lets you test an event pattern against a sample event before creating the rule. aws events put-events sends test events to a bus in a test environment.
To observe asynchronous results, tests can poll the expected outcome, such as a DynamoDB item or an S3 object, or add a temporary rule that copies events to a CloudWatch log group or SQS queue for inspection. EventBridge archive and replay re-sends real past events to test fixes, and the Schema Registry provides typed event bindings.