Passthrough input to output in AWS Step Functions

怎甘沉沦 提交于 2019-12-10 04:22:59

问题


How can I passthrough the input to a Task state in an AWS Step Functions to the output?

After reading the Input and Output Processing page in the AWS docs, I have played with various combinations of InputPath, ResultPath and OutputPath.

State definition:

"First State": {
    "Type": "Task",
    "Resource": "[My Lambda ARN]",
    "Next": "Second State",
    "InputPath": "$.someKey",
    "OutputPath": "$"
}

Input:

{
    "someKey": "someValue"
}

Expected Result

I would like the output of the First State (and thus the input of Second State) to be

{
    "someKey": "someValue"
}

Actual Result

[empty]

What if the input is more complicated, e.g.

{
    "firstKey": "firstValue",
    "secondKey": "secondValue"
}

I would like to forward all of it without worrying about (sub) paths.


回答1:


In the the Amazon States Language it is stated that:

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.

Consequently, I updated my state definition to

"First State": {
    "Type": "Task",
    "Resource": "[My Lambda ARN]",
    "Next": "Second State",
    "ResultPath": null
}

As a result, when passing the input example Task input payload will be copied to the output, even for rich objects like:

{
    "firstKey": "firstValue",
    "secondKey": "secondValue"
}


来源:https://stackoverflow.com/questions/47650838/passthrough-input-to-output-in-aws-step-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!