【发布时间】:2017-07-20 13:58:40
【问题描述】:
我在包含两个分支的 step 函数中有一个并行任务。 输入是:
{
"database": "test",
"userName": "tester",
"userID": "test123",
"adGroup": "testADGroup",
"dbGroup": "ReadGroup"
}
每个分支都返回一个json结果,如下所示
分支 1(我使用“OutputPath”:“$”):
{
"requestType": "GrantAccess",
"DBUser": "exists",
"ADUser": "exists"
}
分支 2(我使用“ResultPath”:“$.approvalStatus”):
{
"database": "test",
"userName": "tester",
"userID": "test123",
"adGroup": "testADGroup",
"dbGroup": "ReadGroup"
"approvalStatus": "Approved"
}
当两个分支都完成后,并行任务的输出返回:
[
{
"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 格式而不是数组返回?
提前致谢
【问题讨论】:
-
所以我想我已经通过在并行任务中添加
"ResultPath":"$.request",将branch2"ResultPath": "$.approvalStatus"更改为"OutputPath": "$",并将以下任务中的所有引用更改为"Variable": "$.request[1].approvalStatus"来解决它跨度> -
2) 我同意。如果他们像 node Async 模块那样做,并让您在对象而不是数组中指定并行状态,然后将结果放入具有相应属性名称的对象中,那就太好了。并行结果依赖数组索引会使代码变得脆弱。
标签: amazon-web-services aws-lambda jsonpath aws-step-functions