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

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

在计算机上运行 Step Functions Local

使用 Step Functions 的本地版本配置、开发和测试计算机上的状态机。

在本地运行 HelloWorld 状态机

在本地使用 Amazon Command Line Interface (Amazon CLI) 运行 Step Functions 后,您可以启动状态机执行。

  1. 在 Amazon CLI 中,通过转义状态机定义来创建状态机。

    aws stepfunctions --endpoint-url http://localhost:8083 create-state-machine --definition "{\ \"Comment\": \"A Hello World example of the Amazon States Language using a Pass state\",\ \"StartAt\": \"HelloWorld\",\ \"States\": {\ \"HelloWorld\": {\ \"Type\": \"Pass\",\ \"End\": true\ }\ }}" --name "HelloWorld" --role-arn "arn:aws:iam::012345678901:role/DummyRole"
    注意

    role-arn 不用于 Step Functions Local,但您必须使用正确的语法包含它。您可以使用前面示例中的 Amazon 资源名称 (ARN)。

    如果您成功创建状态机,Step Functions 将使用创建日期和状态机 ARN 做出响应。

    { "creationDate": 1548454198.202, "stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:HelloWorld" }
  2. 使用创建的状态机的 ARN 启动执行。

    aws stepfunctions --endpoint-url http://localhost:8083 start-execution --state-machine-arn arn:aws:states:us-east-1:123456789012:stateMachine:HelloWorld

Step Functions Local 与 Amazon SAM CLI Local

您可以将 Step Functions 的本地版本与 Amazon Lambda 的本地版本结合使用。要对此进行配置,您必须安装和配置 Amazon SAM。

有关配置和运行 Amazon SAM 的信息,请参阅以下内容:

在您的本地系统上运行 Lambda 后,您可以启动 Step Functions Local。从提取 Step Functions 本地 JAR 文件的目录中,启动 Step Functions Local,然后使用 --lambda-endpoint 参数配置本地 Lambda 端点。

java -jar StepFunctionsLocal.jar --lambda-endpoint http://127.0.0.1:3001 command

有关将 Step Functions Local 与 Amazon Lambda 一起运行的更多信息,请参阅测试 Step Function 和 Amazon SAM CLI Local