Course outline · 0% complete

0/27 lessons0%

Course overview →

Triggers and events

lesson 7-2 · ~10 min · 20/27

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.

triggerevent saystypical job
API Gateway (a managed HTTPS endpoint in front of Lambda)method, path, bodyserve an API endpoint
S3bucket + key of a new objectmake a thumbnail, scan an upload
EventBridge scheduleit is timenightly cleanup, scheduled reports
SQS queuea batch of messagesbackground 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.

S3 bucketphotos/Lambdamake-thumbnailS3 bucketthumbnails/event: new objectwrites resultupload → event → function runs → output stored, no server involved
An event-driven pipeline: the upload itself triggers the function. The function runs for a few hundred milliseconds, writes the thumbnail, and nothing is billed until the next upload.

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.)