【问题标题】:How do I make copies of a value from input?如何从输入中复制值?
【发布时间】:2020-04-10 12:00:31
【问题描述】:

我正在尝试使用步进函数迭代一小组文件。我调用 lambda 来获取文件列表,作为我的处理循环的输入。

我的输入,进入迭代部分:

{
    "name": "ConfigureIterator",
    "input": {
        "files": {
            "count": 3,
            "filelist": [
                "foo",
                "bar",
                "fizz"
            ]
        }
    }
}

My Pass 状态定义:

"ConfigureIterator": {
    "Type": "Pass",
    "Result": {
        "index": -1,
        "step": 1,
        "count": "$.files.count"
    },
    "ResultPath": "$.iterator",
    "Next": "Iterator"
}

我想将count 的值从输入复制到通过步骤的结果中。然而,替换不会发生。输出:

  {
    "name": "ConfigureIterator",
    "output": {
        "files": {
        "count": 11,
        "filelist": [
            ...
        ]
        },
        "iterator": {
        "index": -1,
        "step": 1,
        "count": "$.files.count"
        }
    }
  }

通过状态不执行替换吗?我应该改用任务状态吗?如何定义“无所事事”任务状态?

【问题讨论】:

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


    【解决方案1】:

    即使在 2020 年,“通过”状态的“结果”字段似乎也不会插入值。但是,Parameters 字段可以。 Pass 状态的定义是它把它的输入传递给它的输出。因此,如果您能以您想要的形式获得您的输入,您将自动获得您想要的输出。换句话说,只需将“结果”替换为“参数”就可以了。换句话说:

    "ConfigureIterator": {
        "Type": "Pass",
        "Parameters": {
            "index": -1,
            "step": 1,
            "count.$": "$.files.count"
        },
        "ResultPath": "$.iterator",
        "Next": "Iterator"
    }

    【讨论】:

    • 您忘记了结尾的 '。 $' 它应该是: "count.$": "$.files.count"
    猜你喜欢
    • 2022-11-29
    • 2021-12-24
    • 1970-01-01
    • 1970-01-01
    • 2019-01-22
    • 1970-01-01
    • 2011-04-10
    • 2022-01-05
    • 1970-01-01
    相关资源
    最近更新 更多