[英]Nested map in AWS step function with task inside second map having both map values
I am trying to replicate nested for loop in AWS step function using nested maps.我正在尝试使用嵌套映射在 AWS 步骤 function 中复制嵌套 for 循环。
Example例子
xArr : ["A", "B", "C]
YArr : ["1", "2", "3]
In normal Java program i would do as below.在正常的 Java 程序中,我会做如下。
for (String x : xArr) {
for (String y : yArr) {
// do some computation with both x and y variable
}
}
I am trying to achieve the same using step function with below input.我正在尝试使用以下输入的步骤 function 来实现相同的目的。
{
"xArr": [
"A",
"B",
"C"
],
"yArr": [
"1",
"2",
"3"
]
}
Step function definition diagram步骤function定义图
Is this possible in step function?这在步骤 function 中可能吗?
I tried but i am not able to pass both X and Y variable to the task inside the second map.我试过了,但我无法将 X 和 Y 变量都传递给第二个 map 中的任务。
Had a more complex task with varying inner loop count (items01/items02).有一个更复杂的任务,具有不同的内部循环计数 (items01/items02)。 Should also work with static inner loop (items03 instead of 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"
]
}
Added the lines to get items03 and item03.添加了获取 items03 和 item03 的行。 Replace any other item(s)02 with item(s)03:
将任何其他项目 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.