失败的不是 Step Function,而是一次迭代
Fail not the Step Function but the one iteration
我已经用 Iterator 创建了一个 Step Function 并为其添加了 Catch 任务:
{
"StartAt": "Reader",
"States": {
"Reader": {
"Type": "Task",
"Resource": "arn:aws:lambda:reader",
"Next": "Processing"
},
"Processing": {
"Type": "Map",
"ItemsPath": "$",
"MaxConcurrency": 1,
"Next": "Success",
"Iterator": {
"StartAt": "ProcessFixes",
"States": {
"ProcessFixes": {
"Type": "Task",
"Resource": "arn:aws:lambda:processing",
"Next": "Processed",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"MaxAttempts": 2
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "ProcessingFailed"
}
]
},
"ProcessingFailed": {
"Type": "Fail"
},
"Processed": {
"Type": "Pass",
"End": true
}
}
}
},
"Success": {
"Type": "Succeed"
}
}
}
步骤如下:
所以目前当出现异常时,它会导致整个 Step Function 进程失败。
我需要让迭代之一失败并标记为失败。所以 'Pass' 任务对我不起作用。
最好在“地图迭代详细信息”选项卡中将其显示为失败:
将 ProcessingFailed
从 Fail
更改为 Pass
。将 success: boolean
键添加到两个映射分支的输出。地图任务完成后,您可以根据需要处理成功(success: true
)和失败(success: false
)情况。
"Processed": {
"Type": "Pass",
"Result": {
"success":true,
},
"ResultPath": "$.result",
"Next": "End"
}
"ProcessingFailed": {
"Type": "Pass",
"Result": {
"success":false,
},
"ResultPath": "$.result",
"Next": "End"
}
我已经用 Iterator 创建了一个 Step Function 并为其添加了 Catch 任务:
{
"StartAt": "Reader",
"States": {
"Reader": {
"Type": "Task",
"Resource": "arn:aws:lambda:reader",
"Next": "Processing"
},
"Processing": {
"Type": "Map",
"ItemsPath": "$",
"MaxConcurrency": 1,
"Next": "Success",
"Iterator": {
"StartAt": "ProcessFixes",
"States": {
"ProcessFixes": {
"Type": "Task",
"Resource": "arn:aws:lambda:processing",
"Next": "Processed",
"Retry": [
{
"ErrorEquals": [
"States.ALL"
],
"MaxAttempts": 2
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "ProcessingFailed"
}
]
},
"ProcessingFailed": {
"Type": "Fail"
},
"Processed": {
"Type": "Pass",
"End": true
}
}
}
},
"Success": {
"Type": "Succeed"
}
}
}
步骤如下:
所以目前当出现异常时,它会导致整个 Step Function 进程失败。 我需要让迭代之一失败并标记为失败。所以 'Pass' 任务对我不起作用。
最好在“地图迭代详细信息”选项卡中将其显示为失败:
将 ProcessingFailed
从 Fail
更改为 Pass
。将 success: boolean
键添加到两个映射分支的输出。地图任务完成后,您可以根据需要处理成功(success: true
)和失败(success: false
)情况。
"Processed": {
"Type": "Pass",
"Result": {
"success":true,
},
"ResultPath": "$.result",
"Next": "End"
}
"ProcessingFailed": {
"Type": "Pass",
"Result": {
"success":false,
},
"ResultPath": "$.result",
"Next": "End"
}