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: 10 minutes 🎯 Main Learning: S3 Files gives POSIX access at S3 prices: 13x cheaper than EFS for large files, but the 60-second write-back delay silently breaks coordination patterns! πŸ“ Blog Post πŸ’» GitHub Repository 🎬 Watch on YouTube Hey Reader πŸ‘‹πŸ½ Sandro is currently traveling through Portugal - work and fun combined! If you happen to be around, reach out. Would be great to meet up! 🀝 This week we're digging into S3 Files: a POSIX file system backed by...

AWS FOR THE REAL WORLD ⏱️ Reading time: 6 minutes 🎯 Main Learning: 5 common AWS account mistakes and how to fix each one in under 10 minutes 🎬 Watch on YouTube Hey Reader πŸ‘‹πŸ½ New week, new AWS deep dive 🐠 In this one, we'll show you the 5 most common mistakes we've seen in almost every AWS account we've looked at. Yes, there are more out there. But these are the ones you'll see everywhere. And they're pretty simple to fix! The good news? Most of these fixes take under 10 minutes. Rather watch...

AWS FOR THE REAL WORLD ⏱️ Reading time: 9 minutes 🎯 Main Learning: Build a self-service portal that grants temporary AWS + Azure access and revokes it automatically β€” using Kestra and one YAML file. πŸ“ Blog Post πŸ’» GitHub Repository 🎬 Watch on YouTube Hey Reader πŸ‘‹πŸ½ Happy new week! Tobi and I met up last week and spent some time planning the videos ahead. We’re going more and more into YouTube β€” and a few things I’m hyped about: The biggest AWS mistakes we’ve made (so you don’t have to) How...