【问题标题】:How to insert the input from a step to a json struct and pass to next step in step functions?如何将步骤中的输入插入到 json 结构并传递到步骤函数中的下一步?
【发布时间】:2018-07-06 19:54:24
【问题描述】:

我想要在步骤函数中做的是我的第一步生成一个输出,在下一步中我希望将该输出插入到一个 json 中并作为输出生成。

例如:

第 1 步的输出:HelloWorld

第 2 步的输入:HelloWorld

第 2 步的输出:

myData : {
 data : HelloWorld
}

我试过下面的状态机,但是失败了。

        {
          "Comment": "Sample State Machine",
          "StartAt": "StartTask",
          "States": {
              "StartTask": {
                "Type": "Pass",
                "Result": "Hello World!",
                "Next": "RefactorTask"
            },
            "RefactorTask": {
            "Type": "Pass",
                "Result" : {
                "$" : "$"
            },
            "ResultPath" : "$.myData.data"
        }
    }
}

错误:

 {
  "error": "States.ReferencePathConflict",
  "cause": "Unable to apply step \"myData\" to input \"Hello World!\""
}

【问题讨论】:

    标签: amazon-web-services aws-step-functions


    【解决方案1】:

    第一个状态的输出是“Hello World”。

    意思是RefactorTask的输入是……“Hello World”!这是一个字符串,而不是一个对象,所以它没有任何属性。

    您是否尝试直接在 StartTask 中设置您的 "ResultPath" 而不是添加 Pass 状态?

    {
          "Comment": "Sample State Machine",
          "StartAt": "StartTask",
          "States": {
              "StartTask": {
                "Type": "Pass",
                "Result": "Hello World!",
                "ResultPath" : "$.myData.data",
                "Next": "Whatever is your next task"
            }
    }
    

    否则你可以用并行状态来做......但这似乎有点过头了,不是吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-15
      • 2012-01-03
      • 1970-01-01
      • 2022-08-18
      • 1970-01-01
      相关资源
      最近更新 更多