【问题标题】:Branch Flow in AWS Step Function Based on Number of Items in ArrayAWS Step Function 中基于数组中的项目数的分支流程
【发布时间】:2019-09-21 03:31:24
【问题描述】:

我想根据数组中有多少项来分支 AWS 状态机的流程。如果数组有 0 个项目,我想结束流程。如果它有超过 0 个项目,我想做一些事情。

例如,我想做如下的事情:

{
  "StartAt": "IsBig",
  "States": {
    "IsBig": {
      "Type": "Choice",
      "Choices": [
        {
          "Variable": "$.things.length",
          "NumericGreaterThan": 0,
          "Next": "Big"
        }
      ],
      "Default": "Small"
    },
    "Big": {
      "Type": "Pass",
      "Result": "1",
      "End": true
    },
    "Small": {
      "Type": "Pass",
      "Result": "0",
      "End": true
    }
  }
}

然后我会在执行时传递以下内容:

{ "things": [1, 2, 3] }

我希望IsBig 然后调用Big 并结束。

有没有办法在 AWS 状态语言中做到这一点?

如果我不能,我将创建一个获取数组长度的 Lambda。我只是好奇。

【问题讨论】:

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


    【解决方案1】:

    答案是“不”。您无法从 "Variable": "$.things.length" 属性运行函数。

    Variable 字段中的值是一个.... 变量。这不是一种表达方式。 docs 不显示任何表达式求值语法。所以,长话短说,你不能做我想做的事。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-10
      相关资源
      最近更新 更多