What invokes a function?
A Lambda function never runs on its own. Something triggers it, and each trigger delivers a differently-shaped event to the handler. This wiring is the real payoff of serverless: services glued together with no polling loops and no always-on watcher process to host, patch, and pay for.
| trigger | event says | typical job |
|---|---|---|
| API Gateway (a managed HTTPS endpoint in front of Lambda) | method, path, body | serve an API endpoint |
| S3 | bucket + key of a new object | make a thumbnail, scan an upload |
| EventBridge schedule | it is time | nightly cleanup, scheduled reports |
| SQS queue | a batch of messages | background jobs |
The schedule row replaces cron, the classic Unix scheduler that runs commands at fixed times: an EventBridge schedule is cron as a managed service, with no machine left running just to keep time.
The S3 one deserves a pause: storage events as code triggers is a genuinely new pattern. Upload cats/whiskers.jpg to the bucket from lesson 4-1, and S3 itself invokes your thumbnail function with that key in the event. No polling loop, no queue to build, no server watching for files.
Code exercise · bash
An API Gateway event carries the method and path, and a one-function API dispatches on them, which in bash is a case statement. Your turn: the starter routes GET /todos and rejects everything else. Add a case for POST /todos -> create_todo, then call the handler for GET /todos, POST /todos, and DELETE /nope, in that order.
Quiz
A report generator must run every night at 02:00 with no user involved. Which trigger fits?
Problem
Your app must create a thumbnail every time a user uploads a photo, using the pipeline pattern from this lesson. Which AWS service is the TRIGGER, the one that emits the event? (One service name.)