# AWS Step Functions

> A flowchart that runs: it chains steps, retries failures and remembers where it was.

- Level: Advanced
- Topics: AWS
- URL: https://tidbit.legios.com.ar/aws-step-functions/
- In Spanish: [AWS Step Functions](https://tidbit.legios.com.ar/es/aws-step-functions/)

**AWS Step Functions** orchestrates processes that have many steps. You describe a **state machine**: step A, then B; if B fails retry it three times; then C and D in parallel; wait 24 hours; then E. Each step calls something, most often an AWS Lambda function, but also Amazon ECS tasks, Amazon SQS, Amazon DynamoDB and most AWS APIs. Step Functions runs the flow, tracks exactly where every execution is, and shows it as a live diagram.

The problem it solves: once a process has several steps, someone has to answer 'what if step 3 fails after step 2 already charged the card?'. Writing that logic inside one big function is fragile, and a crashed process forgets everything. A state machine keeps its state outside your code, so an execution can pause for days and pick up again, and a failure in one step triggers the retry or the compensation you defined.

Example: a loan application. Validate the form (Lambda), run a credit check (an external API with a 2-minute timeout and retries), then in parallel calculate the offer and generate the PDF. Then wait for the applicant to sign, up to 7 days, paused at no cost. Then open the account. If any step fails for good, a notification goes out through Amazon SNS.

Definitions are written in a JSON dialect called Amazon States Language, or drawn in the visual Workflow Studio. Standard workflows can run for up to a year; Express workflows are for short, high-volume flows that finish in under five minutes.

## An analogy

A production-line foreman with a clipboard. The foreman builds nothing, but knows which station every product is at, sends it back when a station fails, and never loses track even when the shift changes.

## Keep in mind

- A state machine defines sequence, choices, parallel branches, waits and retries.
- State lives in the service, not in your code: an execution can pause for days and survive crashes.
- Every execution is visible as a diagram with the input and output of each step.
- Standard workflows for long processes, Express for fast, high-volume ones.

## Go deeper

- [What is AWS Step Functions? (official docs)](https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html)
- [AWS Step Functions product page](https://aws.amazon.com/step-functions/)

## Related terms

- [AWS Lambda](https://tidbit.legios.com.ar/aws-lambda/): Run a piece of code only when something happens, with no server to manage.
- [Amazon ECS and Fargate](https://tidbit.legios.com.ar/amazon-ecs-and-fargate/): AWS runs your containers; with Fargate you never see the servers at all.
- [Amazon SQS](https://tidbit.legios.com.ar/amazon-sqs/): A waiting line for messages between programs, so none of them gets lost.
- [Amazon DynamoDB](https://tidbit.legios.com.ar/amazon-dynamodb/): A key-value database that answers in milliseconds no matter how big the table gets.
- [API](https://tidbit.legios.com.ar/api/): The menu of things one program lets another program ask for.
- [Amazon SNS](https://tidbit.legios.com.ar/amazon-sns/): One message in, many copies out: a megaphone for systems.
- [JSON](https://tidbit.legios.com.ar/json/): The plain-text format programs use to hand each other structured data.
- [Amazon](https://tidbit.legios.com.ar/amazon/): An online store with its own delivery network, and the company that runs AWS.
