AWS Step Functions
开发人员指南
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

使用 Step Functions 管理 Amazon ECS/Fargate 任务

Step Functions can control some AWS services directly from the Amazon 状态语言. For more information, see:

支持的 Amazon ECS API 和语法:

注意

Parameters in Step Functions are expressed in PascalCase, even when the native service API is camelCase.

注意

对于 Overrides 参数,Step Functions 不支持将 executionRoleArntaskRoleArn 用作 ContainerOverrides

将数据传递给 Amazon ECS 任务

Step Functions can control some AWS services directly from the Amazon 状态语言. For more information, see:

您可以使用 overrides 覆盖容器的默认命令,并将输入传递给 ECS 任务。请参阅 ContainerOverride。在该示例中,我们使用 JsonPath 将值从输入中的任务传递给任务状态。

下面是一个运行 Amazon ECS 任务并等待任务完成的 Task 状态。

{ "StartAt": "Run an ECS Task and wait for it to complete", "States": { "Run an ECS Task and wait for it to complete": { "Type": "Task", "Resource": "arn:aws:states:::ecs:runTask.sync", "Parameters": { "Cluster": "cluster-arn", "TaskDefinition": "job-id", "Overrides": { "ContainerOverrides": [ { "Name": "container-name", "Command.$": "$.commands" } ] } }, "End": true } } }

对于上述示例,如果执行的输入是:

{ "commands": [ "test command 1", "test command 2", "test command 3" ] }

ContainerOverrides 中的 "Command.$": "$.commands" 行将命令从状态输入传递到容器。

For information on how to configure IAM when using Step Functions with other AWS services, see 集成服务的 IAM 策略.