Amazon web services 如何参考AWS step函数并行任务输出?

Amazon web services 如何参考AWS step函数并行任务输出?,amazon-web-services,aws-lambda,jsonpath,aws-step-functions,Amazon Web Services,Aws Lambda,Jsonpath,Aws Step Functions,我在step函数中有一个并行任务,它包含两个分支。 投入是: { "database": "test", "userName": "tester", "userID": "test123", "adGroup": "testADGroup", "dbGroup": "ReadGroup" } 每个分支返回一个json结果,如下所示 分支1(我使用了“OutputPath”:“$”): 分支2(我使用了“ResultPath”:“$.approvalStatus”): 当两个

我在step函数中有一个并行任务,它包含两个分支。 投入是:

{
  "database": "test",
  "userName": "tester",
  "userID": "test123",
  "adGroup": "testADGroup",
  "dbGroup": "ReadGroup"
}
每个分支返回一个json结果,如下所示

分支1(我使用了“OutputPath”:“$”):

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

当两个分支都完成时,并行任务的输出返回:

[
  {
      "requestType": "GrantAccess",
      "DBUser": "exists",
      "ADUser": "exists"
  },
  {
      "database": "test",
      "userName": "tester",
      "userID": "test123",
      "adGroup": "testADGroup",
      "dbGroup": "ReadGroup"
      "approvalStatus": "Approved"
  }
]
下一个任务是选择

"Choices": [
    {
      "Variable": "$.input[1].approvalStatus",
      "StringEquals": "Approved",
      "Next": "ProcessRequest"
    },
    {
      "Variable": "$.input[1].approvalStatus",
      "StringEquals": "Declined",
      "Next": "SendDeclineNotification"
    }
  ]
它一直在给我以下错误:

"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."
下面是我的问题

1) 我应该如何在选择任务中引用它来获得
approvalStatus

2) 我是否可以用json格式而不是数组返回并行任务


提前谢谢

我想如果你不想更改结果路径,你应该使用类似于“$[1].approvalStatus”的东西。

所以我想我已经解决了这个问题,在并行任务中添加了“ResultPath”:“$.request”“ResultPath”:“$.approvalStatus”到“OutputPath”:“$”,并将以下任务中的所有引用更改为
“变量”:“$.request[1].approvalStatus”
2)我同意。如果他们像node Async模块那样,让您在对象中而不是数组中指定并行状态,然后将结果放入具有相应属性名称的对象中,那就太好了。对并行结果依赖数组索引会使代码变得脆弱。@user3646699这应该是可以接受的答案。
"Choices": [
    {
      "Variable": "$.input[1].approvalStatus",
      "StringEquals": "Approved",
      "Next": "ProcessRequest"
    },
    {
      "Variable": "$.input[1].approvalStatus",
      "StringEquals": "Declined",
      "Next": "SendDeclineNotification"
    }
  ]
"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."