繁体   English   中英

在 AWS 步骤 function 中嵌套 map,第二个 map 中的任务具有两个 map 值

[英]Nested map in AWS step function with task inside second map having both map values

我正在尝试使用嵌套映射在 AWS 步骤 function 中复制嵌套 for 循环。

例子

xArr : ["A", "B", "C]
YArr : ["1", "2", "3]

在正常的 Java 程序中,我会做如下。

for (String x : xArr) {
 for (String y : yArr) {
  // do some computation with both x and y variable
 }
}

我正在尝试使用以下输入的步骤 function 来实现相同的目的。

{
  "xArr": [
    "A",
    "B",
    "C"
  ],
  "yArr": [
    "1",
    "2",
    "3"
  ]
}

步骤function定义图

步骤函数定义图

这在步骤 function 中可能吗?

我试过了,但我无法将 X 和 Y 变量都传递给第二个 map 中的任务。

有一个更复杂的任务,具有不同的内部循环计数 (items01/items02)。 还应该与 static 内循环一起使用(items03 而不是 items02)

{
    "items01": [
        {
            "item01_name": "item01a",
            "items02": [
                {
                    "item02_name": "item02a",
                },{
                    "item02_name": "item02b",
                },{
                    "item02_name": "item02c",
                }
            ]
        },{
            "item01_name": "item01b",
            "items02": [
                {
                    "item02_name": "item02a",
                },{
                    "item02_name": "item02b",
                }
            ]
        }
    ],
    "items03": [
        "item03a", "item03b"
    ]
}

添加了获取 items03 和 item03 的行。 将任何其他项目 02 替换为项目 03:

{
  "StartAt": "map-items01",
  "States": {
    "map-items01":{
      "Type": "Map",
      "ItemsPath": "$.items01",
      "End": true,
      "Parameters": {
        "item01.$": "$$.Map.Item.Value.item01_name",
        "items02.$": "$$.Map.Item.Value.items02",
        "items03.$": "$.items03"
      },
      "Iterator": {
        "StartAt": "map-items02",
        "States": {
          "map-items02":{
            "Type": "Map",
            "ItemsPath": "$.items02",
            "End": true
            "Parameters": {
              "item01.$": "$.item01",
              "item02.$": "$$.Map.Item.Value.item02_name",  
              "item03.$": "$$.Map.Item.Value"
            },
            "Iterator": {
              "StartAt": "run-task01",
              "States": {
                "run-task01": {
                  "Type": "Pass",
                  "End": true
                  "Parameters": {
                    "item01.$": "$.item01",
                    "item02.$": "$.item02",  
                  },
                }
              }
            }
          }
        }
      }
    }
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM