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: 11 minutes 🎯 Main Learning: Most teams should stay serverless. EKS only pays off at real scale. πŸ“ Blog Post Hey Reader πŸ‘‹πŸ½For years we told everyone the same thing: don't run Kubernetes! And we meant it. Running k8s yourself is a second full-time job. Cluster upgrades, etcd backups, some networking plugin that falls over on a Tuesday and nobody can say why.We're serverless people through and through. Lambda first, a queue behind it, scale to zero, go...

AWS FOR THE REAL WORLD ⏱️ Reading time: 12 minutes 🎯 Main Learning: Most of the complaints in the viral "leaving AWS" post are skill issues β€” but egress pricing is a fair hit. πŸ“ Blog Post Hey Reader πŸ‘‹πŸ½Recently, a post with the title "I returned to AWS and was reminded why I left" hit 810 upvotes on Hacker News last week and went pretty viral with it.I read it twice before forming an opinion. My honest take: most of the complaints are skill issues! πŸ€·β™‚οΈNevertheless, the post is well written and...

AWS FOR THE REAL WORLD ⏱️ Reading time: 10 minutes 🎯 Main Learning: Describe the agent: model, prompt, tools and AWS runs the orchestration loop behind one API call! πŸ“ Blog Post Hey Reader πŸ‘‹πŸ½ If you've ever built an agent on AWS, you know the pain: glue Bedrock, Lambda, and DynamoDB together, grab LangGraph or Strands, then also own the orchestration loop, the memory layer, and your own tracing. πŸ˜… A "simple" agent ends up with multiple layers of pain.AWS just shipped something that takes most...