Slide 29
Slide 29 text
After:
複雑な条件分岐を1
つの定義にまとめず切り出す
1 const processMap = new sfn.DistributedMap(this, "ProcessMap", {
2 maxConcurrency: 100,
3 itemsPath: "$.items",
4 itemSelector: {
5 "jobId.$": "$.jobId",
6 "index.$": "$$.Map.Item.Value.index",
7 "inputLocation.$": "$$.Map.Item.Value.location",
8 },
9 resultPath: "$.mapResults",
10 });
11
12 processMap.itemProcessor(processDataTask);
13
14 //
成功・失敗の判定ステート
15 const success = new sfn.Succeed(this, "Success");
16 const failed = new sfn.Fail(this, "Failed", {
17 error: "MapStateError",
18 cause: "Error in map state execution",
19 });
20
21 //
エラーチェックの条件分岐
22 const checkError = new sfn.Choice(this, "CheckError")
23 .when(sfn.Condition.isPresent("$.error"), failed)
24 .otherwise(success);
29