AWS Step Function NumericGreaterThan大于参数

在AWS Step Function的Choice步骤中,我们希望将AWS Lambda函数的结果与使用“ NumericGreaterThan”作为参数给出的阈值进行比较。

在我们的示例中,我们将根据lambda计算出的结果与事件给出的阈值进行了比较。

我尝试通过以下方式定义步进函数:

{
  "StartAt": "Check Enough Data","States": {
    "Check Enough Data": {
      "Type": "Task","Resource": "arn:aws:lambda:REGION:ID:function:FUNCTION:$LATEST","Next": "Validate Count","ResultPath": "$.count"
    },"Validate Count": {
      "Type": "Choice","Choices": [
        {
          "Variable": "$.count","NumericGreaterThan": "$.threshold","Next": "Succeed State"
        }
      ],"Default": "Wait 24 Hours"
    },"Wait 24 Hours": {
      "Type": "Wait","Seconds": 86400,"Next": "Check Enough Data"
    },"Succeed State": {
      "Type": "Succeed"
    }
  }
}

但出现错误类型的预期值:Integer,Float插入了String 。 如果我将“ $ .threshold”替换为硬编码的值(如20),则可以使用,但是该值不是我想要的动态值。

以下输入应使lambda进入成功状态:

{
   "country": "japan","threshold": 40
}

我知道我们可以用另一个Lambda函数代替“选择”步骤,但是我们不想从具有成本效益的问题中做到这一点。

有人对解决问题有想法吗?

ychzd_ok 回答:AWS Step Function NumericGreaterThan大于参数

您可以根据文档https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-choice-state.html

使用'NumericGreaterThanPath'运算符

在选择规则中,可以通过将'Path'附加到受支持的比较运算符的名称来将Variable的值与状态输入中的另一个值进行比较。

NumericEqualsPath,NumericGreaterThanPath,NumericGreaterThanEqualsPath等。

,

比较运算符需要在“:”之后有一个整数。不能是字符串。

一种解决方法是将 “变量”:“ $ .count” 更改为 “ $。count / $。threshold” ,以便您可以使用“ NumericGreaterThan”:1。 在这种情况下,您需要定义“选择”操作的计数和阈值。

让我知道这是否可以解决您的问题

精度:“变量”:“ $。count”变为“变量”:“ $。ratio” 比率=计数/阈值

本文链接:https://www.f2er.com/3144054.html

大家都在问