{"slug":"step-functions","title":"step-functions","summary":"AWS Step Functions workflow orchestration with state machines. Use when designing workflows, implementing error handling, configuring parallel execution, integrating with AWS services, or debugging executions.","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-30T19:53:40.971588Z","repo":{"url":"https://github.com/itsmostafa/aws-agent-skills","stars":1159,"forks":445,"license":"MIT","updatedAt":"2026-09-28T17:13:57Z"},"bodyHtml":"<hr>\n<h2>name: step-functions\ndescription: AWS Step Functions workflow orchestration with state machines. Use when designing workflows, implementing error handling, configuring parallel execution, integrating with AWS services, or debugging executions.\nlast_updated: \"2026-01-07\"\ndoc_source: <a href=\"https://docs.aws.amazon.com/step-functions/latest/dg/\">https://docs.aws.amazon.com/step-functions/latest/dg/</a></h2>\n<h1>AWS Step Functions</h1>\n<p>AWS Step Functions is a serverless orchestration service that lets you build and run workflows using state machines. Coordinate multiple AWS services into business-critical applications.</p>\n<h2>Table of Contents</h2>\n<ul>\n<li><a href=\"#core-concepts\">Core Concepts</a></li>\n<li><a href=\"#common-patterns\">Common Patterns</a></li>\n<li><a href=\"#cli-reference\">CLI Reference</a></li>\n<li><a href=\"#best-practices\">Best Practices</a></li>\n<li><a href=\"#troubleshooting\">Troubleshooting</a></li>\n<li><a href=\"#references\">References</a></li>\n</ul>\n<h2>Core Concepts</h2>\n<h3>Workflow Types</h3>\n<table>\n<thead>\n<tr>\n<th>Type</th>\n<th>Description</th>\n<th>Pricing</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>Standard</strong></td>\n<td>Long-running, durable, exactly-once</td>\n<td>Per state transition</td>\n</tr>\n<tr>\n<td><strong>Express</strong></td>\n<td>High-volume, short-duration</td>\n<td>Per execution (time + memory)</td>\n</tr>\n</tbody>\n</table>\n<h3>State Types</h3>\n<table>\n<thead>\n<tr>\n<th>State</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>Task</strong></td>\n<td>Execute work (Lambda, API call)</td>\n</tr>\n<tr>\n<td><strong>Choice</strong></td>\n<td>Conditional branching</td>\n</tr>\n<tr>\n<td><strong>Parallel</strong></td>\n<td>Execute branches concurrently</td>\n</tr>\n<tr>\n<td><strong>Map</strong></td>\n<td>Iterate over array</td>\n</tr>\n<tr>\n<td><strong>Wait</strong></td>\n<td>Delay execution</td>\n</tr>\n<tr>\n<td><strong>Pass</strong></td>\n<td>Pass input to output</td>\n</tr>\n<tr>\n<td><strong>Succeed</strong></td>\n<td>End successfully</td>\n</tr>\n<tr>\n<td><strong>Fail</strong></td>\n<td>End with failure</td>\n</tr>\n</tbody>\n</table>\n<h3>Amazon States Language (ASL)</h3>\n<p>JSON-based language for defining state machines.</p>\n<h2>Common Patterns</h2>\n<h3>Simple Lambda Workflow</h3>\n<pre><code>{\n  \"Comment\": \"Process order workflow\",\n  \"StartAt\": \"ValidateOrder\",\n  \"States\": {\n    \"ValidateOrder\": {\n      \"Type\": \"Task\",\n      \"Resource\": \"arn:aws:lambda:us-east-1:123456789012:function:ValidateOrder\",\n      \"Next\": \"ProcessPayment\"\n    },\n    \"ProcessPayment\": {\n      \"Type\": \"Task\",\n      \"Resource\": \"arn:aws:lambda:us-east-1:123456789012:function:ProcessPayment\",\n      \"Next\": \"FulfillOrder\"\n    },\n    \"FulfillOrder\": {\n      \"Type\": \"Task\",\n      \"Resource\": \"arn:aws:lambda:us-east-1:123456789012:function:FulfillOrder\",\n      \"End\": true\n    }\n  }\n}\n</code></pre>\n<h3>Create State Machine</h3>\n<p><strong>AWS CLI:</strong></p>\n<pre><code>aws stepfunctions create-state-machine \\\n  --name OrderWorkflow \\\n  --definition file://workflow.json \\\n  --role-arn arn:aws:iam::123456789012:role/StepFunctionsRole \\\n  --type STANDARD\n</code></pre>\n<p><strong>boto3:</strong></p>\n<pre><code>import boto3\nimport json\n\nsfn = boto3.client('stepfunctions')\n\ndefinition = {\n    \"Comment\": \"Order workflow\",\n    \"StartAt\": \"ProcessOrder\",\n    \"States\": {\n        \"ProcessOrder\": {\n            \"Type\": \"Task\",\n            \"Resource\": \"arn:aws:lambda:...\",\n            \"End\": True\n        }\n    }\n}\n\nresponse = sfn.create_state_machine(\n    name='OrderWorkflow',\n    definition=json.dumps(definition),\n    roleArn='arn:aws:iam::123456789012:role/StepFunctionsRole',\n    type='STANDARD'\n)\n</code></pre>\n<h3>Start Execution</h3>\n<pre><code>import boto3\nimport json\n\nsfn = boto3.client('stepfunctions')\n\nresponse = sfn.start_execution(\n    stateMachineArn='arn:aws:states:us-east-1:123456789012:stateMachine:OrderWorkflow',\n    name='order-12345',\n    input=json.dumps({\n        'order_id': '12345',\n        'customer_id': 'cust-789',\n        'items': [{'product_id': 'prod-1', 'quantity': 2}]\n    })\n)\n\nexecution_arn = response['executionArn']\n</code></pre>\n<h3>Choice State (Conditional Logic)</h3>\n<pre><code>{\n  \"StartAt\": \"CheckOrderValue\",\n  \"States\": {\n    \"CheckOrderValue\": {\n      \"Type\": \"Choice\",\n      \"Choices\": [\n        {\n          \"Variable\": \"$.total\",\n          \"NumericGreaterThan\": 1000,\n          \"Next\": \"HighValueOrder\"\n        },\n        {\n          \"Variable\": \"$.priority\",\n          \"StringEquals\": \"rush\",\n          \"Next\": \"RushOrder\"\n        }\n      ],\n      \"Default\": \"StandardOrder\"\n    },\n    \"HighValueOrder\": {\n      \"Type\": \"Task\",\n      \"Resource\": \"arn:aws:lambda:...:function:ProcessHighValue\",\n      \"End\": true\n    },\n    \"RushOrder\": {\n      \"Type\": \"Task\",\n      \"Resource\": \"arn:aws:lambda:...:function:ProcessRush\",\n      \"End\": true\n    },\n    \"StandardOrder\": {\n      \"Type\": \"Task\",\n      \"Resource\": \"arn:aws:lambda:...:function:ProcessStandard\",\n      \"End\": true\n    }\n  }\n}\n</code></pre>\n<h3>Parallel Execution</h3>\n<pre><code>{\n  \"StartAt\": \"ProcessInParallel\",\n  \"States\": {\n    \"ProcessInParallel\": {\n      \"Type\": \"Parallel\",\n      \"Branches\": [\n        {\n          \"StartAt\": \"UpdateInventory\",\n          \"States\": {\n            \"UpdateInventory\": {\n              \"Type\": \"Task\",\n              \"Resource\": \"arn:aws:lambda:...:function:UpdateInventory\",\n              \"End\": true\n            }\n          }\n        },\n        {\n          \"StartAt\": \"SendNotification\",\n          \"States\": {\n            \"SendNotification\": {\n              \"Type\": \"Task\",\n              \"Resource\": \"arn:aws:lambda:...:function:SendNotification\",\n              \"End\": true\n            }\n          }\n        },\n        {\n          \"StartAt\": \"UpdateAnalytics\",\n          \"States\": {\n            \"UpdateAnalytics\": {\n              \"Type\": \"Task\",\n              \"Resource\": \"arn:aws:lambda:...:function:UpdateAnalytics\",\n              \"End\": true\n            }\n          }\n        }\n      ],\n      \"Next\": \"Complete\"\n    },\n    \"Complete\": {\n      \"Type\": \"Succeed\"\n    }\n  }\n}\n</code></pre>\n<h3>Map State (Iteration)</h3>\n<pre><code>{\n  \"StartAt\": \"ProcessItems\",\n  \"States\": {\n    \"ProcessItems\": {\n      \"Type\": \"Map\",\n      \"ItemsPath\": \"$.items\",\n      \"MaxConcurrency\": 10,\n      \"Iterator\": {\n        \"StartAt\": \"ProcessItem\",\n        \"States\": {\n          \"ProcessItem\": {\n            \"Type\": \"Task\",\n            \"Resource\": \"arn:aws:lambda:...:function:ProcessItem\",\n            \"End\": true\n          }\n        }\n      },\n      \"ResultPath\": \"$.processedItems\",\n      \"End\": true\n    }\n  }\n}\n</code></pre>\n<h3>Error Handling</h3>\n<pre><code>{\n  \"StartAt\": \"ProcessWithRetry\",\n  \"States\": {\n    \"ProcessWithRetry\": {\n      \"Type\": \"Task\",\n      \"Resource\": \"arn:aws:lambda:...:function:Process\",\n      \"Retry\": [\n        {\n          \"ErrorEquals\": [\"Lambda.ServiceException\", \"Lambda.TooManyRequestsException\"],\n          \"IntervalSeconds\": 2,\n          \"MaxAttempts\": 6,\n          \"BackoffRate\": 2\n        },\n        {\n          \"ErrorEquals\": [\"States.Timeout\"],\n          \"IntervalSeconds\": 5,\n          \"MaxAttempts\": 3,\n          \"BackoffRate\": 1.5\n        }\n      ],\n      \"Catch\": [\n        {\n          \"ErrorEquals\": [\"CustomError\"],\n          \"ResultPath\": \"$.error\",\n          \"Next\": \"HandleCustomError\"\n        },\n        {\n          \"ErrorEquals\": [\"States.ALL\"],\n          \"ResultPath\": \"$.error\",\n          \"Next\": \"HandleAllErrors\"\n        }\n      ],\n      \"End\": true\n    },\n    \"HandleCustomError\": {\n      \"Type\": \"Task\",\n      \"Resource\": \"arn:aws:lambda:...:function:HandleCustom\",\n      \"End\": true\n    },\n    \"HandleAllErrors\": {\n      \"Type\": \"Fail\",\n      \"Error\": \"ProcessingFailed\",\n      \"Cause\": \"An error occurred during processing\"\n    }\n  }\n}\n</code></pre>\n<h2>CLI Reference</h2>\n<h3>State Machine Management</h3>\n<table>\n<thead>\n<tr>\n<th>Command</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>aws stepfunctions create-state-machine</code></td>\n<td>Create state machine</td>\n</tr>\n<tr>\n<td><code>aws stepfunctions update-state-machine</code></td>\n<td>Update definition</td>\n</tr>\n<tr>\n<td><code>aws stepfunctions delete-state-machine</code></td>\n<td>Delete state machine</td>\n</tr>\n<tr>\n<td><code>aws stepfunctions list-state-machines</code></td>\n<td>List state machines</td>\n</tr>\n<tr>\n<td><code>aws stepfunctions describe-state-machine</code></td>\n<td>Get details</td>\n</tr>\n</tbody>\n</table>\n<h3>Executions</h3>\n<table>\n<thead>\n<tr>\n<th>Command</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>aws stepfunctions start-execution</code></td>\n<td>Start execution</td>\n</tr>\n<tr>\n<td><code>aws stepfunctions stop-execution</code></td>\n<td>Stop execution</td>\n</tr>\n<tr>\n<td><code>aws stepfunctions describe-execution</code></td>\n<td>Get execution details</td>\n</tr>\n<tr>\n<td><code>aws stepfunctions list-executions</code></td>\n<td>List executions</td>\n</tr>\n<tr>\n<td><code>aws stepfunctions get-execution-history</code></td>\n<td>Get execution history</td>\n</tr>\n</tbody>\n</table>\n<h2>Best Practices</h2>\n<h3>Design</h3>\n<ul>\n<li><strong>Keep states focused</strong> — one purpose per state</li>\n<li><strong>Use meaningful state names</strong></li>\n<li><strong>Implement comprehensive error handling</strong></li>\n<li><strong>Use Parallel for independent tasks</strong></li>\n<li><strong>Use Map for batch processing</strong></li>\n</ul>\n<h3>Performance</h3>\n<ul>\n<li><strong>Use Express workflows</strong> for high-volume, short tasks</li>\n<li><strong>Set appropriate timeouts</strong></li>\n<li><strong>Limit Map concurrency</strong> to avoid throttling</li>\n<li><strong>Use SDK integrations</strong> when possible (avoid Lambda wrapper)</li>\n</ul>\n<h3>Reliability</h3>\n<ul>\n<li><strong>Retry transient errors</strong></li>\n<li><strong>Catch and handle specific errors</strong></li>\n<li><strong>Use idempotent operations</strong></li>\n<li><strong>Enable X-Ray tracing</strong></li>\n</ul>\n<h3>Cost Optimization</h3>\n<ul>\n<li><strong>Use Express for short workflows</strong> (&lt; 5 minutes)</li>\n<li><strong>Combine related operations</strong> to reduce transitions</li>\n<li><strong>Use Wait states</strong> instead of Lambda delays</li>\n</ul>\n<h2>Troubleshooting</h2>\n<h3>Execution Failed</h3>\n<pre><code># Get execution history\naws stepfunctions get-execution-history \\\n  --execution-arn arn:aws:states:us-east-1:123456789012:execution:MyWorkflow:exec-123 \\\n  --query 'events[?type==`TaskFailed` || type==`ExecutionFailed`]'\n</code></pre>\n<h3>Lambda Timeout</h3>\n<p><strong>Causes:</strong></p>\n<ul>\n<li>Lambda running too long</li>\n<li>Task timeout too short</li>\n</ul>\n<p><strong>Fix:</strong></p>\n<pre><code>{\n  \"Type\": \"Task\",\n  \"Resource\": \"arn:aws:lambda:...\",\n  \"TimeoutSeconds\": 300,\n  \"HeartbeatSeconds\": 60\n}\n</code></pre>\n<h3>State Stuck</h3>\n<p><strong>Check:</strong></p>\n<ul>\n<li>Task state waiting for callback</li>\n<li>Wait state not yet elapsed</li>\n<li>Activity worker not responding</li>\n</ul>\n<h3>Invalid State Machine</h3>\n<pre><code># Validate definition\naws stepfunctions validate-state-machine-definition \\\n  --definition file://workflow.json\n</code></pre>\n<h2>References</h2>\n<ul>\n<li><a href=\"https://docs.aws.amazon.com/step-functions/latest/dg/\">Step Functions Developer Guide</a></li>\n<li><a href=\"https://docs.aws.amazon.com/step-functions/latest/apireference/\">Step Functions API Reference</a></li>\n<li><a href=\"https://docs.aws.amazon.com/cli/latest/reference/stepfunctions/\">Step Functions CLI Reference</a></li>\n<li><a href=\"https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html\">Amazon States Language</a></li>\n</ul>\n","files":[{"path":"SKILL.md","sizeBytes":9709,"isText":true},{"path":"workflow-patterns.md","sizeBytes":8970,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-30T19:54:28.758952Z","sha256":"C7ED803F942BB288408320D49C10C8006C5CDEC6E5B8F20E401AC16E13D1C7EB","sizeBytes":5414},"review":null,"source":{"repositoryUrl":"https://github.com/itsmostafa/aws-agent-skills","path":"skills/step-functions","license":"MIT","commit":"e786d25128a6018d42bd7bcb8c47c531ff31c0f0","subtreeSha":"4F4EDF7110F7FF4F0C1CD603372672996E4C5732A23516DE4A486FD17DBECAB3","lastSyncedAt":"2026-09-30T19:53:38.659374Z"},"reviewedAt":"2026-09-30T20:02:17.787253Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/itsmostafa/aws-agent-skills/tree/main/skills/step-functions"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install itsmostafa-aws-agent-skills@llmmart"},{"target":"git","command":"git clone https://github.com/itsmostafa/aws-agent-skills.git"}]}