AWS Step Functions
AWS LabsOfficialPublished by AWS Labs
- Skill
- Tool integration
- Cloud and DevOps
- Apache-2.0
- No issues found
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
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/awslabs/aws-step-functions/downloadUnzip 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
$statesreserved variableWorkflow variables with
AssignError 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
| Standard | Express | |
|---|---|---|
| Max duration | 1 year | 5 minutes |
| Execution semantics | Exactly-once | At-least-once (async) / At-most-once (sync) |
| Execution history | Retained 90 days, queryable via API | CloudWatch Logs only |
| Max throughput | 2,000 exec/sec | 100,000 exec/sec |
| Pricing model | Per state transition | Per execution count + duration |
.sync / .waitForTaskToken | Supported | Not supported |
| Best for | Auditable, non-idempotent operations | High-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 JSONPathKeep
Outputminimal — only include what the state immediately after the current state needsUse
Assignto store variables needed in later states instead of threading it through OutputUse
$states.inputto reference original state inputRemember:
AssignandOutputare evaluated in parallel — variable assignments inAssignare NOT available inOutputof the same stateAll JSONata expressions must produce a defined value —
$data.nonExistentFieldthrowsStates.QueryEvaluationErrorUse
$states.context.Execution.Inputto access the original workflow input from any stateSave state machine definitions with
.asl.jsonextension when working outside the consolePrefer 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.inputinstead.Forgetting
{% %}delimiters around JSONata expressions — the string will be treated as a literal.Assigning variables in
Assignand expecting them inOutputof 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
- ATTRIBUTION.mdAdded by AutoGineer922 B
- LICENSELicence file added by AutoGineer9.9 KiB
- NOTICELicence file added by AutoGineer89 B
- SKILL.md7.4 KiB
- examples/compensation-saga-pattern.asl.json3.5 KiB
- examples/express-standard-handoff.asl.json2.2 KiB
- examples/human-in-the-loop-with-timeout-escalation.asl.json3.4 KiB
- examples/nested-map-parallel-structures.asl.json2.0 KiB
- examples/polling-loop-wait-check-choice.asl.json2.0 KiB
- examples/scatter-gather-with-partial-results.asl.json2.2 KiB
- examples/semaphore-concurrency-lock.asl.json3.3 KiB
- references/architecture-patterns.md3.8 KiB
- references/asl-state-types.md12.4 KiB
- references/error-handling.md6.9 KiB
- references/migrating-from-jsonpath-to-jsonata.md13.3 KiB
- references/processing-state-inputs-and-outputs.md11.2 KiB
- references/service-integrations.md6.4 KiB
- references/transforming-data.md6.2 KiB
- references/validation-and-testing.md11.0 KiB
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 JSONPathParameters)Output: Transform the resultAssign: Store variables from input or resultTimeoutSeconds: Max task duration (default 99999999, accepts JSONata expression)HeartbeatSeconds: Heartbeat interval (must be < TimeoutSeconds)Retry: Retry policy arrayCatch: Error handler arrayCredentials: Cross-account role assumption
Choice State
Uses Choices and Condition fields with JSONata boolean expressions to implement branching logic.
Key points:
Conditionmust evaluate to a boolean.Each Choice Rule can have its own
AssignandOutput.If a rule matches, its
Assign/Outputare used (not the state-level ones).If no rule matches, the state-level
Assignis evaluated andDefaultis followed.Defaultis optional but recommended — without it,States.NoChoiceMatchedis thrown.Choice states cannot be terminal (no
Endfield).
"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:
Argumentsprovides 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
Outputon 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
| Field | Description |
|---|---|
Items | JSON array, JSON object, or JSONata expression evaluating to an array or object |
ItemProcessor | State machine to run for each item (has StartAt and States) |
ItemSelector | Reshape each item before processing |
MaxConcurrency | Max parallel iterations (0 = unlimited, 1 = sequential) |
ToleratedFailurePercentage | 0-100, percentage of items allowed to fail |
ToleratedFailureCount | Number of items allowed to fail |
ItemReader | Read items from an external resource |
ItemBatcher | Batch items into sub-arrays |
ResultWriter | Write 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. Usearn:aws:states:::s3:getObjectfor single files orarn:aws:states:::s3:listObjectsV2for listing objects.Arguments— JSON object specifyingBucket,Key(for getObject), orPrefix(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_FLATTENreads and processes the actual data objects, eliminating the need for nested Maps.ManifestType— Optional.ATHENA_DATAfor Athena UNLOAD manifests,S3_INVENTORYfor S3 inventory reports. WhenS3_INVENTORY, do not specifyInputType.CSVDelimiter— Optional, for CSV/MANIFEST. Valid values:COMMA(default),PIPE,SEMICOLON,SPACE,TAB.CSVHeaderLocation— Optional, for CSV/MANIFEST.FIRST_ROWuses the file's first line.GIVENrequires aCSVHeadersarray in the config.CSVHeaders— Array of column name strings. Required whenCSVHeaderLocationisGIVEN.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:
WriterConfigonly — formats output without exporting to S3.Resource+Argumentsonly — exports to S3 without additional formatting.All three — formats and exports.
Sub-fields:
Resource—arn:aws:states:::s3:putObjectArguments— JSON object withBucketandPrefix. Values accept JSONata expressions.WriterConfig— Configuration object:Transformation—NONE(includes execution metadata),COMPACT(output only, preserves array structure), orFLATTEN(output only, flattens nested arrays into one).OutputType—JSON(array) orJSONL(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.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download aws-step-functions.zip