Aws Step Functions

作者 awslabs097fe8ad56d8无许可证915 个星标收录于 2026年10月8日更新于 2026年10月8日仓库今天更新

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.

仅含说明DevOps & Cloud
AI 生成的概览

指导使用 JSONata 编写 AWS Step Functions 状态机的 Amazon States Language 技能。

功能
该技能为使用 Amazon States Language(ASL)编写 AWS Step Functions 状态机提供参考指导,涵盖状态类型、变量、数据转换、错误处理、服务集成、验证与测试,以及从 JSONPath 迁移到 JSONata。它指向随附的参考文档和示例 .asl.json 定义,涉及轮询循环、saga 补偿、分散-聚集、信号量锁定和人工介入升级等模式。它还包含 Standard 与 Express 工作流的快速对比以及常见故障排查说明。
适用场景
适用于构建或审查 Step Functions 工作流、在 Standard 与 Express 工作流之间做选择,或将现有状态机从 JSONPath 迁移到 JSONata 的场景。也适合查询 ASL 状态类型、错误处理、服务集成模式和测试方法。
运行要求
不含脚本,仅为说明与参考文档。实际使用所描述的 AWS 服务需要 AWS 账户和相应权限,但该技能本身除智能体外无需其他依赖。

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 [blocked]
  • Error handling, troubleshooting, Retry, Catch, fallback, error codes, States.Timeout, States.ALL → see references/error-handling.md [blocked]
  • Service integrations, Lambda invoke, DynamoDB, SNS, SQS, SDK integrations, Resource ARN, sync, async → see references/service-integrations.md [blocked]
  • 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 [blocked]
  • 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 [blocked]
  • Architecture patterns, examples, polling, saga, compensation, scatter-gather, semaphore, lock, human-in-the-loop, escalation, Express to Standard → see references/architecture-patterns.md [blocked]
  • Data transformation, JSONata expressions, filtering, aggregation, string operations, $reduce, $lookup, $toMillis, $partition, $parse, $hash, $uuid → see references/transforming-data.md [blocked]
  • 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 [blocked]
  • 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:

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

Or per-state to migrate from JSONPath incrementally:

json
{ "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 [blocked] and references/error-handling.md [blocked] for detailed troubleshooting information.

Resources

来源与署名

来源:awslabs/agent-plugins位于plugins/aws-serverless/skills/aws-step-functions提交097fe8a

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架