Generated banner for AWS Step Functions
Generated logo for AWS Step Functions

AWS Step Functions

AWS LabsOfficialPublished by AWS Labs

  • Skill
  • Tool integration
  • Cloud and DevOps
  • Apache-2.0
  • No issues found

From the author

Build workflows with AWS Step Functions state machines using the JSONata query language. Covers Amazon States Language (ASL) structure, state types, variables, data transformation, error handling, AWS service integration, and migrating from the JSONPath to the JSONata query language.
— the description by AWS Labs

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides comprehensive documentation and patterns for defining workflows in AWS Step Functions. It focuses on the Amazon States Language (ASL) and the use of JSONata for data transformation and logic. The skill covers the eight core state types, error handling, service integrations, and best practices for migrating from legacy JSONPath to JSONata. It also includes architectural patterns such as the Saga pattern, polling loops, and semaphore locks to help developers design robust distributed applications.

What it does

  • Explains ASL structure and the eight available state types.
  • Provides syntax guidance for JSONata expressions in state machines.
  • Details error handling strategies using Retry and Catch blocks.
  • Outlines patterns for AWS service integrations like Lambda, DynamoDB, and SQS.
  • Offers architectural templates for common workflow challenges.
  • Provides instructions for migrating existing state machines from JSONPath to JSONata.

When to use it

  • When designing distributed applications or orchestrating microservices on AWS.
  • When building data or machine learning pipelines that require automated processes.
  • When implementing complex logic like retries, error handling, or branching in cloud workflows.
  • When transitioning state machine definitions to use JSONata for data transformation.

Advantages

  • Centralized reference for ASL syntax and JSONata expressions.
  • Includes ready-to-use architectural patterns for common distributed system problems.
  • Clear guidance on state input/output management and variable assignment.
  • Provides comparative analysis between Standard and Express workflow types.

Usage examples

“How do I implement a retry policy in a Task state?”
The agent provides the syntax for the Retry field, explaining how to define error codes, interval seconds, and max attempts within an ASL Task state.
“Show me how to use JSONata to transform output in a Pass state.”
The agent provides a code example demonstrating the use of the Output field with JSONata expressions to format data dynamically.
“What is the difference between Standard and Express workflows?”
The agent returns a comparison table detailing differences in execution duration, throughput, pricing, and history retention.
“How do I migrate my state machine from JSONPath to JSONata?”
The agent explains the replacement of JSONPath fields like InputPath and ResultPath with the new Arguments and Output fields, and provides migration steps.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/awslabs/aws-step-functions/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip aws-step-functions.zip -d .agents/skills

Documentation by AWS Labs

AWS Step Functions

Overview

AWS Step Functions uses Amazon States Language (ASL) to define state machines as JSON. With AWS Step Functions, you can create workflows, also called State machines, to build distributed applications, automate processes, orchestrate microservices, and create data and machine learning pipelines.

This skill provides comprehensive guidance for writing state machines in ASL, covering:

  • ASL structure and JSONata expression syntax

  • Details on the eight available workflow states

  • The $states reserved variable

  • Workflow variables with Assign

  • Error handling

  • AWS Service integration patterns

  • Example code for data transformation and architecture

  • Validation and testing of state machines

  • How to migrate from JSONPath to JSONata

When to Load Reference Files

Load the appropriate reference file based on what the user is working on:

  • ASL structure, state types, Task, Pass, Choice, Wait, Succeed, Fail, Parallel, Map → see references/asl-state-types.md

  • Error handling, troubleshooting, Retry, Catch, fallback, error codes, States.Timeout, States.ALL → see references/error-handling.md

  • Service integrations, Lambda invoke, DynamoDB, SNS, SQS, SDK integrations, Resource ARN, sync, async → see references/service-integrations.md

  • Migrating from JSONPath to JSONata, migration, JSONPath to JSONata, InputPath, Parameters, ResultSelector, ResultPath, OutputPath, intrinsic functions, Iterator, payload template → see references/migrating-from-jsonpath-to-jsonata.md

  • Validation, linting, testing, TestState, test state, mock, mocking, unit test, inspection level, DEBUG, TRACE, validate state, test in isolation → see references/validation-and-testing.md

  • Architecture patterns, examples, polling, saga, compensation, scatter-gather, semaphore, lock, human-in-the-loop, escalation, Express to Standard → see references/architecture-patterns.md

  • Data transformation, JSONata expressions, filtering, aggregation, string operations, $reduce, $lookup, $toMillis, $partition, $parse, $hash, $uuid → see references/transforming-data.md

  • State input/output, $states, Assign, Output, Arguments, variable scope, variable limits, evaluation order, passing data between states → see references/processing-state-inputs-and-outputs.md

  • Deployment, SAM, CloudFormation, IaC, DefinitionSubstitutions, X-Ray tracing, logging → see the aws-serverless-deployment skill or deploy-on-aws plugin

Quick Reference

Standard vs Express Workflows
StandardExpress
Max duration1 year5 minutes
Execution semanticsExactly-onceAt-least-once (async) / At-most-once (sync)
Execution historyRetained 90 days, queryable via APICloudWatch Logs only
Max throughput2,000 exec/sec100,000 exec/sec
Pricing modelPer state transitionPer execution count + duration
.sync / .waitForTaskTokenSupportedNot supported
Best forAuditable, non-idempotent operationsHigh-volume, idempotent event processing

Choose Standard for: payment processing, order fulfillment, compliance workflows, anything that must never execute twice.

Choose Express for: IoT data ingestion, streaming transformations, mobile backends, high-throughput short-lived processing.

Setting the State Machine Query Language

JSONata is the modern, preferred way to reference and transform data in ASL. It replaces the five JSONPath I/O fields (InputPath, Parameters, ResultSelector, ResultPath, OutputPath) with just two: Arguments (inputs) and Output.

Enable at the top level to apply to all states:

{ "QueryLanguage": "JSONata", "StartAt": "...", "States": {...} }

Or per-state to migrate from JSONPath incrementally:

{ "Type": "Task", "QueryLanguage": "JSONata", ... }

JSONPath is still supported and is the default if QueryLanguage is omitted — existing state machines do not need to be migrated.

Best Practices

  • Set "QueryLanguage": "JSONata" at the top level for new state machines unless the user wants to use JSONPath

  • Keep Output minimal — only include what the state immediately after the current state needs

  • Use Assign to store variables needed in later states instead of threading it through Output

  • Use $states.input to reference original state input

  • Remember: Assign and Output are evaluated in parallel — variable assignments in Assign are NOT available in Output of the same state

  • All JSONata expressions must produce a defined value — $data.nonExistentField throws States.QueryEvaluationError

  • Use $states.context.Execution.Input to access the original workflow input from any state

  • Save state machine definitions with .asl.json extension when working outside the console

  • Prefer the optimized Lambda integration (arn:aws:states:::lambda:invoke) over the SDK integration

Troubleshooting

Common Errors
  • States.QueryEvaluationError — JSONata expression failed. Check for type errors, undefined fields, or out-of-range values.

  • Mixing JSONPath fields with JSONata fields in the same state.

  • Using $ or $$ at the top level of a JSONata expression — use $states.input instead.

  • Forgetting {% %} delimiters around JSONata expressions — the string will be treated as a literal.

  • Assigning variables in Assign and expecting them in Output of the same state — new values only take effect in the next state.

  • Reference references/validation-and-testing.md and references/error-handling.md for detailed troubleshooting information.

Resources

Files

references/asl-state-types.md

ASL Structure and State Types (JSONata Mode)

Quick reference for the eight state types in AWS Step Functions.

See processing-state-inputs-and-outputs.md for details about the fields available inside each state.

Pass State

Passes input to output, optionally transforming it with JSONata. Useful for injecting or transforming data. Without Output, the Pass state copies input to output unchanged.

"SetupAndGreet": {
  "Type": "Pass",
  "Assign": {
    "retryCount": 0,
    "maxRetries": 3,
    "config": "{% $states.input.configuration %}"
  },
  "Output": {
    "greeting": "{% 'Hello, ' & $states.input.name %}",
    "timestamp": "{% $now() %}"
  },
  "Next": "ProcessItem"
}

Task State

Executes work via AWS service integrations, activities, or HTTP APIs. Reference service-integrations.md for full details.

Required Fields
  • Resource: ARN identifying the task to execute

Optional Fields
  • Arguments: Input to the task (replaces JSONPath Parameters)

  • Output: Transform the result

  • Assign: Store variables from input or result

  • TimeoutSeconds: Max task duration (default 99999999, accepts JSONata expression)

  • HeartbeatSeconds: Heartbeat interval (must be < TimeoutSeconds)

  • Retry: Retry policy array

  • Catch: Error handler array

  • Credentials: Cross-account role assumption


Choice State

Uses Choices and Condition fields with JSONata boolean expressions to implement branching logic.

Key points:

  • Condition must evaluate to a boolean.

  • Each Choice Rule can have its own Assign and Output.

  • If a rule matches, its Assign/Output are used (not the state-level ones).

  • If no rule matches, the state-level Assign is evaluated and Default is followed.

  • Default is optional but recommended — without it, States.NoChoiceMatched is thrown.

  • Choice states cannot be terminal (no End field).

"RouteOrder": {
  "Type": "Choice",
  "Choices": [
    {
      "Condition": "{% $states.input.orderType = 'express' %}",
      "Next": "ExpressShipping"
    },
    {
      "Condition": "{% $states.input.total > 100 %}",
      "Assign": {
        "discount": "{% $states.input.total * 0.1 %}"
      },
      "Output": {
        "total": "{% $states.input.total * 0.9 %}"
      },
      "Next": "ApplyDiscount"
    },
    {
      "Condition": "{% $states.input.priority >= 5 and $states.input.category = 'urgent' %}",
      "Next": "PriorityQueue"
    }
  ],
  "Default": "StandardProcessing",
  "Assign": {
    "routedDefault": true
  }
}

JSONata supports rich boolean logic:

"Condition": "{% $states.input.age >= 18 and $states.input.age <= 65 %}"
"Condition": "{% $states.input.status = 'active' or $states.input.override = true %}"
"Condition": "{% $not($exists($states.input.error)) %}"
"Condition": "{% $contains($states.input.email, '@') %}"
"Condition": "{% $count($states.input.items) > 0 %}"
"Condition": "{% $states.input.score >= $threshold %}"

Wait State

Delays execution for a specified duration or until a timestamp.

"DynamicWait": {
  "Type": "Wait",
  "Seconds": "{% $states.input.delaySeconds %}",
  "Next": "Continue"
}
Wait Until Timestamp
"WaitUntilDate": {
  "Type": "Wait",
  "Timestamp": "{% $states.input.scheduledTime %}",
  "Next": "Execute"
}

Timestamps must conform to RFC3339 (e.g., "2026-03-14T01:59:00Z").

A Wait state must contain exactly one of Seconds or Timestamp.


Succeed State

Terminates the state machine (or a Parallel branch / Map iteration) successfully.

"Done": {
  "Type": "Succeed",
  "Output": {
    "status": "completed",
    "processedAt": "{% $now() %}"
  }
}

Fail State

Terminates the state machine with an error.

"DynamicFail": {
  "Type": "Fail",
  "Error": "{% $states.input.errorCode %}",
  "Cause": "{% $states.input.errorMessage %}"
}

Reference error-handling.md for more information.


Parallel State

Executes multiple branches concurrently. All branches receive the same input.

Key points:

  • Arguments provides input to each branch's StartAt state (optional, defaults to state input).

  • Result is an array with one element per branch, in the same order as Branches.

  • If any branch fails, the entire Parallel state fails (unless caught).

  • States inside branches can only transition to other states within the same branch.

  • Branch variables are scoped — branches cannot access each other's variables.

  • Use Output on terminal states within branches to pass data back to the outer scope.


Map State

Iterates over a JSON array or a JSON object, processing each element (potentially in parallel). See examples/nested-map-parallel-structures.asl.json for a complete state machine example combining Map + Parallel states.

Key Map Fields
FieldDescription
ItemsJSON array, JSON object, or JSONata expression evaluating to an array or object
ItemProcessorState machine to run for each item (has StartAt and States)
ItemSelectorReshape each item before processing
MaxConcurrencyMax parallel iterations (0 = unlimited, 1 = sequential)
ToleratedFailurePercentage0-100, percentage of items allowed to fail
ToleratedFailureCountNumber of items allowed to fail
ItemReaderRead items from an external resource
ItemBatcherBatch items into sub-arrays
ResultWriterWrite results to an external resource
Map ProcessorConfig

The ItemProcessor can include a ProcessorConfig to control execution mode.

  • INLINE (default) — iterations run within the parent execution. Use for most cases.

  • DISTRIBUTED — iterations run as child executions. Use for large-scale processing (thousands+ items), items read from S3, or when you need per-iteration execution history.

"ProcessOrders": {
  "Type": "Map",
  "Items": "{% $states.input.orders %}",
  "MaxConcurrency": 10,
  "ItemProcessor": {
    "ProcessorConfig": { "Mode": "INLINE" },
    "StartAt": "ProcessOne",
    "States": {
      "ProcessOne": {
        "Type": "Task",
        "Resource": "arn:aws:states:::lambda:invoke",
        "Arguments": {
          "FunctionName": "arn:aws:lambda:us-east-1:123456789012:function:ProcessOrder:$LATEST",
          "Payload": "{% $states.input %}"
        },
        "Output": "{% $states.result.Payload %}",
        "End": true
      }
    }
  },
  "Assign": { "orderResults": "{% $states.result %}" },
  "Next": "Done"
}
Map Failure Tolerance

Use ToleratedFailurePercentage (0–100) and/or ToleratedFailureCount to allow partial failures. The Map state fails if either threshold is breached.

ItemReader (Distributed Map only, optional)

Specifies a dataset and its location for a Distributed Map state. Omit when iterating over JSON data from a previous state.

Sub-fields:

  • Resource — The S3 API action. Use arn:aws:states:::s3:getObject for single files or arn:aws:states:::s3:listObjectsV2 for listing objects.

  • Arguments — JSON object specifying Bucket, Key (for getObject), or Prefix (for listObjectsV2). Values accept JSONata expressions.

  • ReaderConfig — Configuration object with the following sub-fields:

    • InputType — Required for most sources. Valid values: CSV, JSON, JSONL, PARQUET, MANIFEST.

    • Transformation — Optional. NONE (default) iterates over metadata from ListObjectsV2. LOAD_AND_FLATTEN reads and processes the actual data objects, eliminating the need for nested Maps.

    • ManifestType — Optional. ATHENA_DATA for Athena UNLOAD manifests, S3_INVENTORY for S3 inventory reports. When S3_INVENTORY, do not specify InputType.

    • CSVDelimiter — Optional, for CSV/MANIFEST. Valid values: COMMA (default), PIPE, SEMICOLON, SPACE, TAB.

    • CSVHeaderLocation — Optional, for CSV/MANIFEST. FIRST_ROW uses the file's first line. GIVEN requires a CSVHeaders array in the config.

    • CSVHeaders — Array of column name strings. Required when CSVHeaderLocation is GIVEN.

    • ItemsPointer — Optional, for JSON files. Uses JSONPointer syntax (e.g., /data/items) to select a nested array or object within the file.

    • MaxItems — Optional. Limits the number of items processed. Accepts an integer or a JSONata expression evaluating to a positive integer. Maximum: 100,000,000.

S3 buckets must be in the same AWS account and Region as the state machine.

ItemSelector (optional)

Overrides the values of input items before they are passed to each iteration. Accepts a JSON object with key-value pairs. Values can be static or JSONata expressions. Can access the map state's context object. Available in both Inline and Distributed Map states.

ItemBatcher (Distributed Map only, optional)

Groups items into batches for processing. Each child workflow execution receives an Items array and an optional BatchInput object. You must specify at least one of:

  • MaxItemsPerBatch — Maximum number of items per batch. Accepts an integer or a JSONata expression evaluating to a positive integer.

  • MaxInputBytesPerBatch — Maximum batch size in bytes (up to 256 KiB). Accepts an integer or a JSONata expression evaluating to a positive integer.

  • BatchInput — Optional. Fixed JSON merged into each batch. Values accept JSONata expressions.

If both MaxItemsPerBatch and MaxInputBytesPerBatch are specified, Step Functions reduces the item count to stay within the byte limit.

ResultWriter (Distributed Map only, optional)

Controls output formatting and optional export of child workflow execution results to S3. The ResultWriter field cannot be empty — specify at least one of the following combinations:

  • WriterConfig only — formats output without exporting to S3.

  • Resource + Arguments only — exports to S3 without additional formatting.

  • All three — formats and exports.

Sub-fields:

  • Resource — arn:aws:states:::s3:putObject

  • Arguments — JSON object with Bucket and Prefix. Values accept JSONata expressions.

  • WriterConfig — Configuration object:

    • Transformation — NONE (includes execution metadata), COMPACT (output only, preserves array structure), or FLATTEN (output only, flattens nested arrays into one).

    • OutputType — JSON (array) or JSONL (JSON Lines).

When exporting, Step Functions writes SUCCEEDED_n.json, FAILED_n.json, and PENDING_n.json files plus a manifest.json to the specified S3 location. Individual result files are capped at 5 GB. The S3 bucket must be in the same account and Region as the state machine.

Without ResultWriter, the Map state returns an array of child execution results directly. If the output exceeds 256 KiB, the execution fails with States.DataLimitExceeded — use ResultWriter to export to S3 instead.

Distributed Map State Example
"ProcessCSV": {
  "Type": "Map",
  "MaxConcurrency": 100,
  "ToleratedFailurePercentage": 5,
  "ItemReader": {
    "Resource": "arn:aws:states:::s3:getObject",
    "ReaderConfig": {
      "InputType": "CSV",
      "CSVHeaderLocation": "FIRST_ROW"
    },
    "Arguments": {
      "Bucket": "{% $states.input.bucket %}",
      "Key": "{% $states.input.key %}"
    }
  },
  "ItemProcessor": {
    "ProcessorConfig": {
      "Mode": "DISTRIBUTED",
      "ExecutionType": "EXPRESS"
    },
    "StartAt": "ProcessRow",
    "States": {
      "ProcessRow": {
        "Type": "Task",
        "Resource": "arn:aws:states:::lambda:invoke",
        "Arguments": {
          "FunctionName": "arn:aws:lambda:us-east-1:123456789012:function:ProcessRow:$LATEST",
          "Payload": "{% $states.input %}"
        },
        "Output": "{% $states.result.Payload %}",
        "End": true
      }
    }
  },
  "ResultWriter": {
    "Resource": "arn:aws:states:::s3:putObject",
    "Arguments": {
      "Bucket": "{% $states.input.bucket %}",
      "Prefix": "results"
    }
  },
  "Next": "Done"
}

Requirements and compatibility

Written for: Claude Code

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Claude Code frontmatter

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
AWS Labs
Publisher
AWS Labs (Official)
Source
awslabs/agent-plugins · plugins/aws-serverless/skills/aws-step-functions · commit fbefb37
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • NOTICE (added by AutoGineer from NOTICE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by AWS Labs or AWS Labs.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download aws-step-functions.zip