I always go Lambda-first. Except for this.


AWS FOR THE REAL WORLD
⏱️
Reading time: 8 minutes
🎯
Main Learning: How to pause Step Function workflows for human approval using the callback pattern
📝

Hey Reader 👋🏽

I've used this pattern in almost every project I've built.

Whenever you need a human in the loop - approvals, reviews, manual checks - and you still want to see what's happening, Step Functions are perfect.

Lambda is my go-to for almost everything.

  • APIs
  • S3 triggers
  • event consumers

But for workflows where someone needs to approve or reject something? I always reach for Step Functions. In this issue, I'll show you the "Wait for Callback" pattern. We'll build a content moderation system where admins approve or reject blog posts before they go live. Rather watch a video? I've recorded one for you.

video preview

Rather reading it? Check out the deep dive 👇🏽

Step Functions Callback Pattern

📚 This Week's Deep Dive

The Problem with Human-in-the-Loop Workflows

Picture a blogging platform. Users submit posts. Admins review them before they go live.

The tricky part: these happen at different times. A user submits at 9am. An admin reviews at 3pm. How do you connect these?

With Lambda alone, you'd need polling. Save state to a database. Run a CRON job. Check every few minutes if someone approved. It works, but it's ugly.

Step Functions handle this elegantly with the "Wait for Callback" pattern.

How It Works

  1. User submits a blog post through API Gateway
  2. Step Function starts and invokes a Lambda function
  3. Lambda saves the content AND a task token to DynamoDB
  4. Step Function pauses - it waits for that token to come back
  5. Admin sees pending posts in a dashboard, clicks approve or reject
  6. Another API call sends the task token back to Step Functions
  7. Step Function resumes and handles the result

The key is that task token. It's like a parking ticket. The workflow hands it out, parks itself, and waits until someone brings the ticket back.

Things to Watch Out For

Token expiration: Tokens can be valid up to one year. We set ours to 7 days.

Token security: Anyone with the token can resume your workflow. Keep them private.

Standard only: This pattern only works with Standard Step Functions (billed per state transition), not Express.

Error handling: A rejected post isn't a failure - it's a valid outcome. Design your error handling accordingly.

Why Not Just Use Lambda?

You could. Save everything to DynamoDB. Poll with EventBridge. Check if approved.

But you lose visibility. Step Functions show you a visual graph of exactly what happened. When something goes wrong, you see the exact state. Non-technical people can look at the diagram and understand the flow.

For approval workflows, that visibility is worth it.

That's it for this week!

The callback pattern is one of those things that once you know it, you'll use it everywhere. Approval workflows, manual QA checks, payment confirmations - anywhere a human needs to be in the loop.

Clone the repo, deploy it to your account, and break things.

See you soon!

Sandro & Tobi

AWS for the Real World

We teach AWS for the real world - not for certifications. Join more than 10,500 developers learning how to build real-world applications on AWS.

Read more from AWS for the Real World

AWS FOR THE REAL WORLD ⏱️ Reading time: 5 minutes 🎯 Main Learning: Deploy AWS's open-source TEAM solution for temporary admin access with approval workflows 🎬 Watch on YouTube Hey Reader 👋🏽 I hope you had a great weekend and have a great week ahead. One thing I see over and over again in AWS setups: admin permissions are either handed out way too easily or way too hard. There is no middle ground. In other systems this was already solved. You shouldn’t have to DM somebody for admin access. We...

AWS FOR THE REAL WORLD ⏱️ Reading time: 12 minutes 🎯 Main Learning: Run an always-on AI agent on a $5 Lightsail instance with zero open ports, SSM access, and GitHub as a time machine for your agent's brain 📝 Blog Post 🎬 Watch on YouTube Hey Reader 👋🏽 the past weeks there is obviously one driving topic: OpenClaw 🦞 We love seeing that a developer from our neighbor country 🇦🇹 built a tool that got so MUCH hype. That is why we needed to try it out as well! While I (Sandro) added OpenClaw to my...

AWS FOR THE REAL WORLD ⏱️ Reading time: 8 minutes 🎯 Main Learning: How to securely connect Claude Code to a private RDS database using MCP, SSM tunnels, and VPC endpoints 📝 Blog Post 💻 GitHub Repository 🎬 Watch on YouTube Hey Reader 👋🏽 AI coding assistants are great. If you give them the right context. Your database schema is one of the most valuable pieces of context you can provide. But there's a problem: your RDS is in a private subnet. As it should be. So how do you connect Claude Code to...