Amazon States Language - Amazon Step Functions
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

Amazon States Language

Amazon States Language 是一种基于 JSON 的结构化语言,用于定义状态机(一个状态集合),可以执行工作(Task 状态),确定哪些状态转换为下一个状态(Choice 状态),在出错的情况下停止执行(Fail 状态)等等。

有关更多信息,请参阅 Amazon States Language 规范Statelint,后者是一个用于验证 Amazon 状态语言代码的工具。

要使用 Amazon States Language 在 Step Functions 控制台上创建状态机,请参阅入门

注意

如果您在 Step Functions 控制台之外定义状态机,例如在自己选择的编辑器中,则必须以 .asl.json 扩展名保存状态机定义。

Amazon States Language 规范示例

{ "Comment": "An example of the Amazon States Language using a choice state.", "StartAt": "FirstState", "States": { "FirstState": { "Type": "Task", "Resource": "arn:aws:lambda:us-east-1:123456789012:function:FUNCTION_NAME", "Next": "ChoiceState" }, "ChoiceState": { "Type" : "Choice", "Choices": [ { "Variable": "$.foo", "NumericEquals": 1, "Next": "FirstMatchState" }, { "Variable": "$.foo", "NumericEquals": 2, "Next": "SecondMatchState" } ], "Default": "DefaultState" }, "FirstMatchState": { "Type" : "Task", "Resource": "arn:aws:lambda:us-east-1:123456789012:function:OnFirstMatch", "Next": "NextState" }, "SecondMatchState": { "Type" : "Task", "Resource": "arn:aws:lambda:us-east-1:123456789012:function:OnSecondMatch", "Next": "NextState" }, "DefaultState": { "Type": "Fail", "Error": "DefaultStateError", "Cause": "No Matches!" }, "NextState": { "Type": "Task", "Resource": "arn:aws:lambda:us-east-1:123456789012:function:FUNCTION_NAME", "End": true } } }