amazon-web-services - 如何引用 AWS step function 并行任务输出?

标签 amazon-web-services aws-lambda jsonpath aws-step-functions

我在包含两个分支的 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值(value)?

2)无论如何我可以让并行任务以json格式而不是数组返回?

提前致谢

最佳答案

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

关于amazon-web-services - 如何引用 AWS step function 并行任务输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45216910/

相关文章:

amazon-web-services - 云形成 : Deleting an entire nested stack

aws-lambda - 如何创建由另一个账户中的kinesis触发的lambda函数?

kubernetes - kubectl jsonpath 查询并输出多个对象值

amazon-web-services - AWS Pricing API 中使用的 AWS ELB 的服务代码是什么

amazon-web-services - 如何在 AWS EC2 而不是 ElastiCache 上安装/管理 Redis 集群?

amazon-web-services - 通过 jenkins 部署到 AWS 时出现 Terraform 版本错误?

node.js - 如何访问 AWS Lambda 中的 header ?

node.js - 查找未设置 DynamoDB 属性*或*大于 x 的项目

java - 使用 jayway JsonPath 解析 Json 时保留尾随零

json - 使用 REST Assured,我如何检查一个字段是否存在于 json 对象类型的响应数组中?