Blog
Thoughts on engineering, design, and building great products.
Step Functions: Orchestrating Multi-Step Workflows and the Saga Pattern
When a process has many steps, branches, and error handling, cramming it all into one Lambda gets messy and hard to read. Step Functions pulls the orchestration logic out into a declarative state machine. Build a link-moderation workflow (safety scan, then activate or reject), with Retry, Catch, and a direct DynamoDB call without Lambda. Covers Standard vs Express, and the saga pattern for undoing a mid-process failure.
EventBridge: Decoupling Click Recording from the Redirect Path
Opening the event-driven part. Instead of counting clicks right inside the redirect handler, every link open publishes an event onto a custom EventBridge event bus, and a separate consumer handles it. Build the bus, have resolve publish the event, attach a consumer via an event pattern, then open a real link to watch the event flow through the bus to the consumer.
Multi-Tenant: Each User Their Own Data Slice, and Blocking IDOR
Turn the URL shortener into a true multi-tenant system. Add a list-links route scoped to the identity in the token, and a delete-link route that checks ownership inside the write operation so one user can't delete another's link even if they guess the code right. Tested with two real users to see the boundary hold.
Cognito and JWT Authorizer: Only Logged-In Users Can Create Links
Add real users with Amazon Cognito. Stand up a user pool that issues JWTs, attach the HTTP API's JWT authorizer to protect the create-link route while the open-link route stays public, and have the handler read the user identity from a claim in the token instead of hard-coding it. Create a real user, get a real token, call the API with and without a token to see the boundary.
Wiring DynamoDB Into Code: Safe Writes and Atomic Counter
Wire the two handlers into the real DynamoDB: create-link writes an item with a conditional write so it never overwrites a duplicate code, resolve-link does a lookup then counts clicks with an atomic counter. Fire many opens in parallel to see the atomic counter count exactly, and hit a real account limit — Lambda concurrency — when 40 of 50 requests come back 503.
Global Secondary Index and Sparse Index: Opening a New Query Path
The single-table from the previous article answers 'open a link by code' fast, but is helpless at 'list a user's links'. This article adds a global secondary index to invert the key and open exactly that query path, then uses a sparse index so the index holds only links and naturally drops the stat records. Create a real GSI, run a real query to see the mechanics.
DynamoDB Single-Table Design: Start From the Questions, Not the Table
DynamoDB design runs opposite to a relational database: you start from the query questions, not from tables. This article lists the URL shortener's access patterns, explains what partition key and sort key actually do, then builds a single-table with an item collection — a link and its click stats live in the same partition and come back in one query. Create a real table, put and query real items to see the mechanics.