简体   繁体   English

如何参考 AWS step function 并行任务输出?

[英]How reference AWS step function parallel task output?

I have a parallel task in the step function that contains two branches.我在包含两个分支的 step 函数中有一个并行任务。 The input was:输入是:

{
  "database": "test",
  "userName": "tester",
  "userID": "test123",
  "adGroup": "testADGroup",
  "dbGroup": "ReadGroup"
}

Each branch return a json result like the following每个分支都返回一个 json 结果,如下所示

Branch 1 (I used "OutputPath": "$"):分支 1(我使用了“OutputPath”:“$”):

{
  "requestType": "GrantAccess",
  "DBUser": "exists",
  "ADUser": "exists"
}

Branch 2 (I used "ResultPath": "$.approvalStatus"):分支 2(我使用了“ResultPath”:“$.approvalStatus”):

{
      "database": "test",
      "userName": "tester",
      "userID": "test123",
      "adGroup": "testADGroup",
      "dbGroup": "ReadGroup"
      "approvalStatus": "Approved"
}

When both the branches complete, the output of the parallel task return:当两个分支都完成时,并行任务的输出返回:

[
  {
      "requestType": "GrantAccess",
      "DBUser": "exists",
      "ADUser": "exists"
  },
  {
      "database": "test",
      "userName": "tester",
      "userID": "test123",
      "adGroup": "testADGroup",
      "dbGroup": "ReadGroup"
      "approvalStatus": "Approved"
  }
]

The next task is a choices,下一个任务是一个选择,

"Choices": [
    {
      "Variable": "$.input[1].approvalStatus",
      "StringEquals": "Approved",
      "Next": "ProcessRequest"
    },
    {
      "Variable": "$.input[1].approvalStatus",
      "StringEquals": "Declined",
      "Next": "SendDeclineNotification"
    }
  ]

and it is keep giving me the following error:它不断给我以下错误:

"cause": "An error occurred while executing the state 'CheckApprovalStatus' (entered at the event id #16). Invalid path '$.input[1].approvalStatus': The choice state's condition path references an invalid value."

So here are my questions,所以这里是我的问题,

1) How should I reference it in the choice task to get the approvalStatus value? 1)我应该如何在选择任务中引用它来获得approvalStatus值?

2) Is there are anyway I can make the parallel task return in json format instead of an array? 2)无论如何我可以让并行任务以json格式而不是数组返回?

Thanks in advance提前致谢

如果您不想更改 ResultPath,我认为您应该使用"$[1].approvalStatus"之类的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM