Stop 11 · Serverless & Event-Driven AppsTopics · 8/10

AWS Step Functions

Part of the AWS Roadmap

In short

Real business processes have many steps: check stock, charge the card, book delivery, send an SMS. Step Functions runs those steps for you, with retries and error paths drawn as a clear diagram.

Step Functions orchestrates multi-step workflows as state machines, with built-in retries, branching, parallel steps and error handling. It replaces fragile chains of Lambda functions calling each other.

The jaadu with a long clipboard checklist ticks off items while decorators, caterers and a band set up around a wedding mandap.

Think of it like this

The wedding planner's checklist

A Jaipur wedding planner works from a checklist: confirm the venue, then the caterer and decorator in parallel, then the band. If the band cancels, she calls the backup. She never forgets where she is, even after a long night. Step Functions is that planner: a state machine that remembers every step, retries and branches when something goes wrong.

Watch it happen

An order workflow execution

Check stock
Charge payment
Choice
Book delivery
Notify

1/5A Task state calls a Lambda function that checks inventory.

The big ideas

What you need to know

State machines

Written in Amazon States Language (JSON). States include Task, Choice, Parallel, Map, Wait, Pass, Succeed and Fail.

Retry and Catch

Declare retries with backoff per error type, and Catch to jump to a recovery state, instead of hand-written try/except chains.

Direct integrations

Call DynamoDB, SNS, SQS, ECS and many other AWS APIs straight from a state, without writing a Lambda for each.

Standard vs Express

Standard workflows can run for up to a year with exactly-once steps. Express workflows are for short, high-volume runs.

See it in code

Walk through the code

json
1{2  "Comment": "Order workflow",3  "StartAt": "ChargePayment",4  "States": {5    "ChargePayment": {6      "Type": "Task",7      "Resource": "arn:aws:states:::lambda:invoke",8      "Arguments": {9        "FunctionName": "charge-payment",10        "Payload": "{% $states.input %}"11      },12      "Output": "{% $states.result.Payload %}",13      "Retry": [{14        "ErrorEquals": ["States.TaskFailed"],15        "IntervalSeconds": 2,16        "MaxAttempts": 3,17        "BackoffRate": 218      }],19      "Catch": [{20        "ErrorEquals": ["States.ALL"],21        "Next": "NotifyFailure"22      }],23      "Next": "BookDelivery"24    },25    "BookDelivery": { "Type": "Pass", "End": true },26    "NotifyFailure": { "Type": "Fail", "Error": "PaymentFailed" }27  },28  "QueryLanguage": "JSONata"29}

1/5Execution starts at ChargePayment.

Amazon States Language using JSONata, the newer query language for Step Functions. Older examples use Parameters and JSONPath instead of Arguments and Output.

Save yourself the pain

Common mistakes

Oops

Chaining Lambdas that call each other directly and wait for responses.

Do this instead

You pay for idle waiting and lose track of failures. Let Step Functions call each step and handle retries.

Oops

Using Express workflows for a process that waits days for human approval.

Do this instead

Express runs are limited to five minutes. Use a Standard workflow with a callback task token for long waits.

Your mission

Draw, then run, a workflow

~35 min

Quick check

Your payment API sometimes times out but succeeds on a second try. Where's the cleanest place to handle that?

Go deeper

  1. 1Build a three-step workflow (validate, process, notify) in Workflow Studio.
  2. 2Add a Retry and Catch block to one step and force a failure.
  3. 3Learn the difference between Standard and Express workflows.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge