teluzia.Cloud Engineer · Day 70
CHAPTER 10 · SERVERLESS AND MESSAGING

Week 10 review, recall and recovery

30–90 min including independent practice6 topicsRecall, catch-up, or rest
LET’S MAKE THIS SIMPLE

What you’re learning today

Trace a queued order from HTTP acceptance to fan-out consumers. Draw API Gateway -> Lambda -> SQS -> worker, plus SNS subscriptions, and an EventBridge rule feeding a Step Functions compensation path. Write five acceptance checks: HTTP contract, duplicate safety, visibility timeout, filter routing, and bounded compensation. Treat the review as a short evidence-based check: use the existing local lab or paper design, record which outcomes you actually reproduced, and repair one named gap before adding more complexity. Do not create extra billable resources just to prove recall.

Think of it this way

A weekly review is a recovery drill: demonstrate the system, inject one controlled mistake, and explain the evidence that proves repair.

TOPIC 01 / 06Step by step

Invocation and handler

Lambda runs a configured handler when an invocation arrives. The event is input data; the context describes the invocation. Synchronous callers wait for a response, while asynchronous callers receive acceptance before execution completes. The function should validate input before performing work and return a contract the caller understands. For example, a Python handler returns {"statusCode": 200, "body": "hello"} for an HTTP integration, but a direct invocation can return ordinary JSON.

WORKED EXAMPLE
A Python handler returns {"statusCode": 200, "body": "hello"} for an HTTP integration, but a direct invocation can return ordinary JSON.
Why this matters

Knowing who waits for the result helps you choose response contracts, retries, error handling, and appropriate monitoring for each invocation path.

A common trap

Do not assume every event has the same structure; API Gateway events and SQS batches need different parsing and error handling logic.

Read all topics in this lesson

A complete reference to revisit alongside the guided steps above.

Invocation and handler

Lambda runs a configured handler when an invocation arrives. The event is input data; the context describes the invocation. Synchronous callers wait for a response, while asynchronous callers receive acceptance before execution completes. The function should validate input before performing work and return a contract the caller understands. For example, a Python handler returns {"statusCode": 200, "body": "hello"} for an HTTP integration, but a direct invocation can return ordinary JSON.

WORKED EXAMPLE
A Python handler returns {"statusCode": 200, "body": "hello"} for an HTTP integration, but a direct invocation can return ordinary JSON.

Why this matters

Knowing who waits for the result helps you choose response contracts, retries, error handling, and appropriate monitoring for each invocation path.

A common trap

Do not assume every event has the same structure; API Gateway events and SQS batches need different parsing and error handling logic.

Routes and integrations

An API separates its public request contract from backend implementation. A route identifies an HTTP method and path; an integration tells API Gateway where to send matching traffic. HTTP APIs and REST APIs differ in features, so choosing one requires checking authorization, transformation, deployment, and operational requirements first. For example, gET /health can integrate with a Lambda handler; POST /orders is a different route even if both use the same function.

WORKED EXAMPLE
GET /health can integrate with a Lambda handler; POST /orders is a different route even if both use the same function.

Why this matters

A precise route table makes client behavior predictable and prevents backend changes from accidentally creating undocumented interfaces that callers learn to depend on.

A common trap

Mixing instructions for REST APIs and HTTP APIs produces incorrect console steps or event parsing because their integration and payload details can differ.

Queue delivery and visibility timeout

SQS decouples producers from workers. Standard queues provide at-least-once delivery and best-effort ordering, so consumers must handle duplicates. Receiving a message temporarily hides it through the visibility timeout. Deleting the message after successful processing acknowledges completion; merely receiving it does not permanently remove it. For example, if work lasts 40 seconds but visibility lasts 10, another worker may receive the same message while the first is still processing.

WORKED EXAMPLE
If work lasts 40 seconds but visibility lasts 10, another worker may receive the same message while the first is still processing.

Why this matters

A correctly sized visibility window prevents avoidable concurrent duplicates while preserving eventual recovery when a worker crashes before it can acknowledge successful work.

A common trap

Deleting a message before its durable side effect finishes can lose work permanently; receiving a message should never be mistaken for completing it.

Topics, publishing, and subscriptions

An SNS topic gives publishers one destination and distributes messages to subscribed endpoints. Subscribers can include queues, functions, or other supported transports. Publishing does not mean every consumer has finished its work. Subscription confirmation, endpoint policies, and delivery permissions determine whether the intended receiver actually accepts the message. For example, an order-created topic fans out to an inventory queue and an audit queue; the producer does not know each worker’s address.

WORKED EXAMPLE
An order-created topic fans out to an inventory queue and an audit queue; the producer does not know each worker’s address.

Why this matters

Fan-out reduces producer coupling and lets independent consumers evolve without rewriting the order service whenever another team needs the same business event.

A common trap

Assuming a successfully accepted publish proves every subscriber processed the message hides unconfirmed subscriptions, denied queue delivery, and downstream worker failures or backlogs.

Event buses, rules, and patterns

EventBridge receives structured events and matches them against rule patterns. Matching events go to configured targets; event content is data, not an instruction to execute arbitrary code. Rules can select source, detail-type, and fields inside detail. Delivery retry and dead-letter settings help protect targets from transient failures. For example, match source com.shop and detail-type OrderCreated, then route only orders whose detail.region is eu to an appropriate processing target.

WORKED EXAMPLE
Match source com.shop and detail-type OrderCreated, then route only orders whose detail.region is eu to an appropriate processing target.

Why this matters

Clear event schemas and narrow matching rules make routing reviewable and keep unrelated events from unexpectedly triggering costly or privileged downstream workflows in production.

A common trap

Treating a pattern as a full JSON equality comparison misses EventBridge matching semantics; test sample matching and nonmatching events before connecting a live target.

End-to-end contract testing

A serverless REST path includes the public method and route, authorization, integration mapping, handler, and persistence. Unit tests isolate code; integration tests exercise boundaries between services. Define requests and observable responses before building, and include malformed input, missing authorization, duplicate requests, and dependency failures in the acceptance contract. For example, pOST /orders with valid JSON returns a created order ID; the same idempotency key returns the existing order rather than a second record.

WORKED EXAMPLE
POST /orders with valid JSON returns a created order ID; the same idempotency key returns the existing order rather than a second record.

Why this matters

Boundary tests catch mismatches between individually correct components, including event shapes and response formats that local handler unit tests cannot reveal by themselves.

A common trap

Calling only the function directly and declaring the public API tested skips authorizers, deployment stages, gateway mapping, and client-visible error status behavior.

KEEP THESE WITH YOU

Today’s takeaways

Invocation and handler: Lambda runs a configured handler when an invocation arrives. The event is input data; the context describes the invocation. Synchronous callers wait for a response, while asynchronous callers receive acceptance before execution completes. The function should validate input before performing work and return a contract the caller understands.

Routes and integrations: An API separates its public request contract from backend implementation. A route identifies an HTTP method and path; an integration tells API Gateway where to send matching traffic. HTTP APIs and REST APIs differ in features, so choosing one requires checking authorization, transformation, deployment, and operational requirements first.

Queue delivery and visibility timeout: SQS decouples producers from workers. Standard queues provide at-least-once delivery and best-effort ordering, so consumers must handle duplicates. Receiving a message temporarily hides it through the visibility timeout. Deleting the message after successful processing acknowledges completion; merely receiving it does not permanently remove it.

Topics, publishing, and subscriptions: An SNS topic gives publishers one destination and distributes messages to subscribed endpoints. Subscribers can include queues, functions, or other supported transports. Publishing does not mean every consumer has finished its work. Subscription confirmation, endpoint policies, and delivery permissions determine whether the intended receiver actually accepts the message.

Event buses, rules, and patterns: EventBridge receives structured events and matches them against rule patterns. Matching events go to configured targets; event content is data, not an instruction to execute arbitrary code. Rules can select source, detail-type, and fields inside detail. Delivery retry and dead-letter settings help protect targets from transient failures.

End-to-end contract testing: A serverless REST path includes the public method and route, authorization, integration mapping, handler, and persistence. Unit tests isolate code; integration tests exercise boundaries between services. Define requests and observable responses before building, and include malformed input, missing authorization, duplicate requests, and dependency failures in the acceptance contract.

CLOSE THE LOOP

Ready to complete this day?

Verify your recall or recovery steps, then finish this review day.

Lab steps verifiedReview day: quiz optional