Serverless Builder
Design and ship an event-driven app with Lambda and DynamoDB.
Before you start: Cloud Starter, or equivalent experience.
The route
- Serverless: Lambda, functions as the unit of compute
AWS Lambda from first principles: the execution environment, synchronous, asynchronous and polling invocations, cold starts, concurrency, and production habits.
- Serverless: API Gateway, the front door
Amazon API Gateway explained: REST, HTTP and WebSocket APIs compared, authorisers, throttling, and when a Lambda function URL is all you need.
- Serverless: DynamoDB, a database designed around access patterns
Amazon DynamoDB from first principles: partition and sort keys, Query vs Scan, secondary indexes, single-table design, capacity modes, and streams.
- Serverless: EventBridge, the event router
Amazon EventBridge explained: event buses, rules and event patterns, targets, archive and replay, EventBridge Pipes, and EventBridge Scheduler.
- Serverless: SQS and SNS, queues and fan-out
Amazon SQS and SNS explained: standard and FIFO queues, visibility timeouts, dead-letter queues, partial batch failures with Lambda, and SNS fan-out.
- Serverless: Step Functions, workflows as state machines
AWS Step Functions explained: Standard vs Express workflows, direct service integrations, retries and catches, parallel and map states, waiting for humans, and when to use Lambda durable functions instead.
- Serverless: event-driven patterns you can ship to production
Pull it together: the patterns that combine everything above in production.
Project: Ship a meetup RSVP service
Build an RSVP API for meetups with a capacity limit and a waitlist: Lambda and DynamoDB behind API Gateway, events published through an outbox to EventBridge, email confirmations from a queue, and a Step Functions workflow that promotes people off the waitlist. Deployed with SAM.
You run a monthly meetup. The room holds a fixed number of people, everyone wants a confirmation email, and when someone drops out, the first person on the waitlist should get their spot (and an email saying so) without you lifting a finger.
This project uses every lesson in the path. It’s a brief, not a tutorial: it tells you what to build and how to check it works, and links back to the lessons for the how. Expect a weekend or a few evenings.
What you’ll build
┌─────────────────────────────────────────────┐
curl ──► HTTP API ──► Lambda ──► DynamoDB table │
│ (one write per change) │
▼ │
DynamoDB Streams │
│ │
EventBridge Pipe (filter, enrich) │
▼ │
Event bus "meetup" │
┌──────────┴───────────┐ │
RsvpConfirmed / Waitlisted RsvpCancelled │
▼ ▼ │
SQS queue ──► DLQ Step Functions: │
▼ PromoteFromWaitlist ─┘
Lambda "notifier" (writes to the table, so the
▼ promotion is published like
SNS topic ──► email any other change)
| Piece | What it does | Lesson |
|---|---|---|
| HTTP API + Lambda | Create events, RSVP, cancel | Lambda, API Gateway |
| DynamoDB | Events, RSVPs and the waitlist in one table; capacity enforced with a transaction | DynamoDB |
| Streams + Pipe + bus | Publishes a domain event for every RSVP change, with no PutEvents in your code (a small Lambda in the Pipe maps each change to an event) |
EventBridge, Transactional outbox |
| SQS + notifier + SNS | Sends confirmation and waitlist emails, buffered and retried | SQS and SNS |
| Step Functions | Promotes the next person when someone cancels | Step Functions |
Before you start
- An AWS account with a budget alert set up.
- The AWS SAM CLI and Python 3.13, to match the lessons’ examples. Any Lambda runtime works.
- One SAM template for the whole project. Deploy after every milestone, not just at the end.
Milestone 1: the API and the table
Build an HTTP API with four routes:
| Route | Does |
|---|---|
POST /events |
Create an event: name, startsAt, capacity |
GET /events/{id} |
The event, with spaces left and waitlist length |
POST /events/{id}/rsvps |
RSVP with email and name; returns CONFIRMED or WAITLISTED |
DELETE /events/{id}/rsvps/{email} |
Cancel an RSVP |
Design the table around those access patterns before writing any code (see single-table design). One shape that works:
| PK | SK | Holds |
|---|---|---|
EVENT#<id> |
META |
name, startsAt, capacity, confirmed count |
EVENT#<id> |
RSVP#<email> |
status, name, createdAt |
Add a sparse GSI with attributes that are set only
while an RSVP is waitlisted, so “who’s next?” is a single Query, oldest first.
The rule that matters: never confirm more people than the room holds, even when two people RSVP
for the last spot in the same millisecond. Do it in one TransactWriteItems call: put the RSVP
with attribute_not_exists(SK), and increment confirmed with the condition
confirmed < capacity. If the capacity condition fails, write the RSVP as WAITLISTED instead.
Done when:
- With
capacity: 2, the first two RSVPs areCONFIRMEDand the third isWAITLISTED. - RSVPing twice with the same email returns the existing RSVP rather than creating a second one.
- No route uses
Scan.
Milestone 2: publish events through an outbox
Turn on DynamoDB Streams (NEW_AND_OLD_IMAGES) and connect it to a custom event bus called
meetup with an EventBridge Pipe. Your Lambda functions never call PutEvents: if the write
succeeded, the event is published; if it didn’t, it isn’t.
Use the Pipe’s filter to keep only RSVP items. Choosing the event type means comparing the old and new status, which an input transformer can’t do, so add a small enrichment Lambda to the Pipe that turns each stream record into a domain event. It still publishes nothing itself: the Pipe does that. Other services should never see DynamoDB JSON (see design events as contracts):
{
"source": "meetup.rsvps",
"detail-type": "RsvpConfirmed",
"detail": { "eventId": "wlg-nov", "email": "ana@example.com", "name": "Ana" }
}
Three detail types: RsvpConfirmed, RsvpWaitlisted and RsvpCancelled. A status change from
WAITLISTED to CONFIRMED is an RsvpConfirmed too. Give RsvpCancelled a previousStatus, so
consumers can tell a freed seat from someone leaving the waitlist.
Done when: a temporary rule sending everything on the bus to a CloudWatch Logs group shows one
clean event for each RSVP and cancellation, and nothing for META updates.
Milestone 3: email notifications from a queue
Add a rule for RsvpConfirmed and RsvpWaitlisted that targets an SQS queue, and a notifier
Lambda that reads the queue and publishes a message to an SNS topic. Subscribe your own email
address to the topic (and confirm the subscription email AWS sends you).
Make it production-shaped:
- A dead-letter queue on the queue, and a DLQ on the EventBridge target.
- Partial batch responses, so one bad message doesn’t retry the whole batch.
- An idempotent consumer: delivery is at least once, so record each event ID you’ve handled (a conditional put in the table, or Powertools idempotency) and skip repeats.
Done when:
- An RSVP produces exactly one email.
- Sending the same event to the queue twice still produces one email.
- A message the notifier can’t handle ends up in the DLQ after its retries, without blocking the rest.
Milestone 4: promote from the waitlist
When someone cancels a CONFIRMED RSVP, a rule on RsvpCancelled (filtered on
previousStatus: CONFIRMED) starts a Standard Step
Functions workflow, PromoteFromWaitlist. Use
direct service integrations, with no
Lambda functions:
- Query the waitlist index for the oldest waitlisted RSVP.
- Choice: nobody waiting? Succeed.
- TransactWriteItems: set that RSVP to
CONFIRMEDand incrementconfirmed, with the capacity condition from milestone 1. - Catch a failed transaction, then GetItem the event. If there’s still a free seat (someone else was promoted, or cancelled, at the same moment), go back to step 1; if it’s full, succeed. Without that check, a full event would loop forever.
The workflow doesn’t send email or publish anything. Its write goes through the outbox like every
other change, so the promoted person gets their RsvpConfirmed email from milestone 3 for free.
That’s orchestration inside, choreography between.
Done when: with a full event and two people waiting, cancelling one confirmed RSVP promotes the
first waitlisted person, they get an email, and GET /events/{id} shows one fewer on the
waitlist.
Milestone 5: make it production-ready
Work through the production checklist. At minimum:
- An alarm on the age of the oldest message in each DLQ.
- Structured logs with the RSVP’s event ID in every line, so you can follow one RSVP through API, stream, queue and workflow.
- X-Ray tracing on the API and Lambda functions.
- Reserved concurrency on the notifier, so a burst can’t exhaust your account’s concurrency.
Test the whole thing
API=https://<your-api-id>.execute-api.<region>.amazonaws.com
curl -s -X POST $API/events -d '{"id":"wlg-nov","name":"November meetup","startsAt":"2026-12-03T17:30:00+13:00","capacity":2}'
for who in ana ben cat dan; do
curl -s -X POST $API/events/wlg-nov/rsvps -d "{\"email\":\"you+$who@example.com\",\"name\":\"$who\"}"
done
# ana, ben: CONFIRMED · cat, dan: WAITLISTED · 4 emails
curl -s -X DELETE $API/events/wlg-nov/rsvps/you+ben@example.com
sleep 5
curl -s $API/events/wlg-nov
# cat is CONFIRMED and got an email; dan is still waiting
Use + addresses on your own email so every message comes to you. Don’t send to real people’s
addresses from a test stack.
Cost and clean-up
Everything here is pay-per-use, so a test run costs very little, and much of it falls within the
free tier. Nothing runs when you’re not calling it. When you’re done, sam delete removes the
stack; check that the SNS subscription and any log groups you created by hand have gone too.
Going further
- Reminders: create a one-off EventBridge Scheduler schedule per event that emails confirmed attendees the day before.
- Secure the admin route: protect
POST /eventswith a JWT authoriser (see securing an API). - Replay: add an archive to the bus, break the notifier, fix it, and replay the events you missed.
- Load-test it: fire a few hundred RSVPs at once and watch the queue absorb the burst while the capacity rule holds.
For bigger examples of these patterns in real projects, see Trivolt (real-time play with AppSync Events) and The Better Store (microservices with sagas and an outbox).
← All paths