如果外部json状态发生变化,如何更改AWS Step函数的状态

时间:2019-02-18 08:19:38

标签: aws-lambda aws-step-functions

我正在使用步进功能设置订购流程,我想执行其状态,并在状态更改时等待1分钟。我使用lambda从外部api创建了一个http / s请求,该请求返回了Order对象。

 "StartAt": "Process Order",
  "States": {
    "Process Order": {
      "Type": "Task",
      "Resource": "arn:aws:lambda:FUNCTIONTOREQUESThttpJSON",
      "Next": "Is Received?"
    },
    "Is Received?":{
      "Type" : "Choice",
        "Choices": [ 
          {
            "Variable": "$.status",
            "StringEquals": "Received",
            "Next": "Received"
          },
          {
            "Variable": "$.status",
            "StringEquals": "Cancelled",
            "Next": "Cancelled"
          }
      ]
    },

    "Received":{
      "Type": "Wait",
      "Seconds": 60,
      "Next": "Is For Approval or Cancelled?"
    },

     "Is For Approval or Cancelled?":{
      "Type" : "Choice",
        "Choices": [ 
          {
            "Variable": "$.status",
            "StringEquals": "For Approval",
            "Next": "nextState"
          },
          {
            "Variable": "$.status",
            "StringEquals": "Cancelled",
            "Next": "nextState"
          }
      ]
    },

比方说,当前状态=“已接收”(来自Lambda函数http请求的json) 如果状态更改为“待批准”,则应进入“待批准”状态。但是,即使我已将其从外部API更改为“待批准”,我仍获得相同的状态值“已接收”。

1 个答案:

答案 0 :(得分:0)

请记住,在AWS Step Functions中,如果您有输入($ .x)且未在状态更改任何ResultPath的状态下使用此($ .x)值,则$ .x的值始终是相同。我看不到您在流程中更改或更新$ .status

的值的地方