How can I pass my input to my output in a task
in AWS Step Functions?
I'm aware of this question, and the docs:
If the value of ResultPath is null, that means that the state’s own raw output is discarded and its raw input becomes its result.
But what I need is:
{
"input": "my_input"
}
{
"output": "my_output"
}
I need to pass to the next state the following json:
{
"input": "my_input",
"output": "my_output"
}
How can I pass my input to my output in a task in AWS Step Functions? If the value of ResultPath is null, that means that the state’s own raw output is discarded and its raw input becomes its result. Two suggestions comes to mind, either Use ResultPath to Replace the Input with the Result, which allows you to
To effectively design and implement workflows in AWS Step Functions, it’s vital to understand the flow of information from one state to another. Still, it’s also crucial to learn how to manipulate and filter this data. In the diagram below, you’ll notice the movement of JSON information throughout a task state:
In case your task state orchestrates an AWS Batch job, you'll easily pass all the relevant API parameters straight to the API actions of that service. The ItemsPath field is utilized in a Map state so you could select an array within the input. A Map state is used to iterate steps for every item within an array found in the input.
Understanding how this information flows from state to state, and learning how to filter and manipulate this data, is key to effectively designing and implementing workflows in AWS Step Functions. In the Amazon States Language, these fields filter and control the flow of JSON from state to state:
For anyone who comes to this question, it's not possible to do what I asked, but what you can do is, according to the docs:
{
"States": {
"my-state": {
"Type": "task",
"ResultPath": "$.response"
}
}
}
This will append whatever the lambda returns into the response
node, resulting in:
{
"input": "my_input",
"response": {
"output": "my_output"
}
}
Two suggestions comes to mind, either Use ResultPath to Replace the Input with the Result, which allows you to
If you don't specify a ResultPath, the default behavior is as if you had specified
"ResultPath": "$"
. Because this tells the state to replace the entire input with the result, the state input is completely replaced by the result coming from the task result.
For this option to work, the Lambda function must return the desired response:
{
"input": "my_input",
"output": "my_output"
}
Alternatively Use ResultPath to Include the Result with the Input in the Step Functions developer guide. Next, if if you change the return value from you Lambda to include just "my_output"
you can specify "ResultPath": "$.output"
to achieve the desired result:
{
"input": "my_input",
"output": "my_output"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With