首页 > 解决方案 > AWS Step 函数 - 选择状态不支持字段参数?

问题描述

我正在尝试创建一个 AWS Step 函数,但它显示了一条错误消息,就像Field Parameters is not supportedParallel 分支内的选择状态一样。我使用了以下代码:

{
"Comment": "A Parallel Step Function",
"StartAt": "ParentStep",
"States":
{
  "ParentStep":
  {
    "Comment": "Parallel test execution to check the Input Flow",
    "Type": "Parallel",
    "End": true,
    "Branches":
    [
        {
            "Comment": "Parallel Execution 1",
            "StartAt": "branch1",
            "States":
            {
                "branch1":
                {
                    "Comment": "branch1 started",
                    "Parameters":
                    {
                        "testvalue1.$": "$.value1"
                    },
                    "Type": "Choice",
                    "Choices":
                    [
                        {
                            "Variable": "$.testvalue1",
                            "NumericEquals": 1,
                            "Next": "subbranch1"
                        },
                        {
                            "Not":
                            {
                                "Variable": "$.testvalue1",
                                "NumericEquals": 1
                            },
                            "Next": "subbranch2"
                        }
                    ],
                    "Default": "subbranch2"
                },
                "subbranch1":
                {
                    "Comment": "sub-branch 1",
                    "Type": "Pass",
                    "End": true
                },
                "subbranch2":
                {
                    "Comment": "Ending branch 1",
                    "Type": "Pass",
                    "End": true
                }
            }
        },
        {
            "Comment": "Parallel Execution 2",
            "StartAt": "branch2",
            "States":
            {
                "branch2":
                {
                    "Comment": "starting branch 2",
                    "Parameters":
                    {
                        "testvalue2.$": "$.value2"
                    },
                    "Type": "Choice",
                    "Choices":
                    [
                        {
                            "Variable": "$.testvalue2",
                            "NumericEquals": 2,
                            "Next": "subbranch3"
                        },
                        {
                            "Not":
                            {
                                "Variable": "$.testvalue2",
                                "NumericEquals": 2
                            },
                            "Next": "subbranch4"
                        }
                    ],
                    "Default": "subbranch4"
                },
                "subbranch3":
                {
                    "Comment": "sub-branch 3",
                    "Type": "Pass",
                    "End": true
                },
                "subbranch4":
                {
                    "Comment": "Ending Parallel Execution 2",
                    "Type": "Pass",
                    "End": true
                }
            }
        }
    ]
}}}

Choice但是,如果我用状态替换状态,则相同的代码可以工作Task。是字段Parameters不支持的Choice状态吗?我浏览了 AWS Step 函数文档,但看不到任何相关信息。有人可以对此有所了解吗?

谢谢

标签: amazon-web-servicesaws-lambdadevopsstate-machineaws-step-functions

解决方案


Parameters不支持atChoice状态。据此您只能使用Choicesand Default。此外,您可以在文档中查看支持哪些字段。顺便说一句,您可以通过以下解决方案来完成您的任务。

{
  "Comment": "A Parallel Step Function",
  "StartAt": "ParentStep",
  "States": {
    "ParentStep": {
      "Comment": "Parallel test execution to check the Input Flow",
      "Type": "Parallel",
      "End": true,
      "Branches": [
        {
          "Comment": "Parallel Execution 1",
          "StartAt": "branch1",
          "States": {
            "branch1": {
              "Comment": "branch1 started",
              "Type": "Choice",
              "Choices": [
                {
                  "Variable": "$.testvalue1",
                  "NumericEquals": 1,
                  "Next": "subbranch1"
                },
                {
                  "Not": {
                    "Variable": "$.testvalue1",
                    "NumericEquals": 1
                  },
                  "Next": "subbranch2"
                }
              ],
              "Default": "subbranch2"
            },
            "subbranch1": {
              "Comment": "sub-branch 1",
              "Type": "Pass",
              "Parameters": {
                "testvalue1.$": "$.value1"
              },
              "End": true
            },
            "subbranch2": {
              "Comment": "Ending branch 1",
              "Type": "Pass",
              "Parameters": {
                "testvalue1.$": "$.value1"
              },
              "End": true
            }
          }
        },
        {
          "Comment": "Parallel Execution 2",
          "StartAt": "branch2",
          "States": {
            "branch2": {
              "Comment": "starting branch 2",
              "Type": "Choice",
              "Choices": [
                {
                  "Variable": "$.testvalue2",
                  "NumericEquals": 2,
                  "Next": "subbranch3"
                },
                {
                  "Not": {
                    "Variable": "$.testvalue2",
                    "NumericEquals": 2
                  },
                  "Next": "subbranch4"
                }
              ],
              "Default": "subbranch4"
            },
            "subbranch3": {
              "Comment": "sub-branch 3",
              "Type": "Pass",
              "Parameters": {
                "testvalue2.$": "$.value2"
              },
              "End": true
            },
            "subbranch4": {
              "Comment": "Ending Parallel Execution 2",
              "Type": "Pass",
              "Parameters": {
                "testvalue2.$": "$.value2"
              },
              "End": true
            }
          }
        }
      ]
    }
  }
}

推荐阅读