Lesson 16 / 26

Lambda Basics

Running code without provisioning or managing servers.

What Lambda is

Lambda runs your code in response to events, without you provisioning or managing any server. You pay only for the milliseconds your function actually runs.

Triggers & use cases

Lambda functions can be triggered by an S3 upload, an API Gateway request, a schedule, a queue message, and more — great for image processing, APIs, and glue code between services.

A minimal handler

The function signature Lambda invokes for each event.

def handler(event, context):
    name = event.get("name", "world")
    return {"statusCode": 200, "body": f"Hello, {name}!"}

Output:

{"statusCode": 200, "body": "Hello, world!"}

An on-call worker

Lambda is like an on-call worker who appears the instant a task arrives, does exactly that job, then leaves — you're never paying them to sit around idle between calls.