Generating Test Events

In this lesson, you will learn​ how to generate test events using `sam local` and how to work with file streams​.

Events coming from S3 will have a different structure to those coming from API Gateway. When you started experimenting with API events in Chapter 6, you used a nice trick to understand the structure: create an empty function that just logs the event to CloudWatch at the start. You could do something similar now, but SAM has another tool that makes this even simpler. You can use sam local generate-event to create sample events.

For example, run this command to see what an S3 object upload event looks like:

sam local generate-event s3 put

Get hands-on with 1000+ tech skills courses.