Pass Parameters to a Service API - AWS Step Functions
AWS services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with AWS services in China.

Pass Parameters to a Service API

Use the "Parameters" field in a Task state to control what parameters are passed to a service API.

Pass Static JSON as Parameters

You can include a JSON object directly in your state machine definition to pass as a parameter to a resource.

For example, to set the RetryStrategy parameter for the SubmitJob API for AWS Batch, you could include the following in your parameters.

"RetryStrategy": { "attempts": 5 }

You can also pass multiple parameters with static JSON. As a more complete example, the following are the "Resource" and "Parameters" fields of the specification of a task that publishes to an Amazon SNS topic.

"Resource": "arn:aws-cn:states:::sns:publish", "Parameters": { "TopicArn": "arn:aws-cn:sns:us-east-1:123456789012:myTopic", "Message": "test message", "MessageAttributes": { "my attribute no 1": { "DataType": "String", "StringValue": "value of my attribute no 1" }, "my attribute no 2": { "DataType": "String", "StringValue": "value of my attribute no 2" } } },

Pass State Input as Parameters Using Paths

You can pass portions of the state input into parameters by using paths. A path is a string, beginning with $, that's used to identify components within JSON text. Step Functions paths use JsonPath syntax.

To specify that a parameter use a path to reference a JSON node in the input, end the parameter name with .$. For example, if you have text in your state input in a node named message, you could pass that to a parameter by referencing the input JSON with a path.

Using the following state input.

{ "comment": "A message in the state input", "input": { "message": "foo", "otherInfo": "bar" }, "data": "example" }

You could pass the message foo as a parameter using the following.

"Parameters": {"Message.$": "$.input.message"},

For more information about using parameters in Step Functions, see the following:

Pass Context Object Nodes as Parameters

In addition to static content, and nodes from the state input, you can pass nodes from the context object as parameters. The context object is dynamic JSON data that exists during a state machine execution. It includes information about your state machine and the current execution. You can access the context object using a path in the "Parameters" field of a state definition.

For more information about the context object and how to access that data from a "Parameters" field, see the following: