AWS Step Functions
Developer Guide

Manage Amazon ECS/Fargate Tasks with Step Functions

Step Functions can control some AWS services directly from the Amazon States Language. For more information, see:

Supported Amazon ECS APIs and syntax:

Note

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

Note

For the Overrides parameter, Step Functions does not support executionRoleArn or taskRoleArn as ContainerOverrides.

Passing data to an Amazon ECS task

Step Functions can control some AWS services directly from the Amazon States Language. For more information, see:

You can use overrides to override the default command for a container, and pass input to your ECS Tasks. See, ContainerOverride. In the example, we have used JsonPath to pass values to the Task from the input to the Task state.

The following includes a Task state that runs an Amazon ECS task and waits for it to complete.

{ "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 } } }

For the above example, if the input to the execution is:

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

The "Command.$": "$.commands" line in ContainerOverrides passes the commands from the state input to the container.

For information on how to configure IAM when using Step Functions with other AWS services, see IAM Policies for Integrated Services.