From 1808212149850ecff5d726797cd0a084e43c51bc Mon Sep 17 00:00:00 2001 From: Anshika Mehndiratta Date: Wed, 23 Aug 2023 19:54:04 +0000 Subject: [PATCH] docs(step-functions): add multi state example for map state --- .../aws-cdk-lib/aws-stepfunctions/README.md | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions/README.md b/packages/aws-cdk-lib/aws-stepfunctions/README.md index bd2749c0b949f..51d17d16c6204 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/README.md +++ b/packages/aws-cdk-lib/aws-stepfunctions/README.md @@ -467,8 +467,27 @@ execute the same steps for multiple entries of an array in the state input. const map = new sfn.Map(this, 'Map State', { maxConcurrency: 1, itemsPath: sfn.JsonPath.stringAt('$.inputForMap'), + parameters: { + item: sfn.JsonPath.stringAt('$$.Map.Item.Value'), + }, + resultPath: '$.mapOutput', }); -map.iterator(new sfn.Pass(this, 'Pass State')); + +// The Map iterator can contain a IChainable, which can be an individual or multiple steps chained together. +// Below example is with a Choice and Pass step +const choice = new sfn.Choice(this, 'Choice'); +const condition1 = sfn.Condition.stringEquals('$.item.status', 'SUCCESS'); +const step1 = new sfn.Pass(this, 'Step1'); +const step2 = new sfn.Pass(this, 'Step2'); +const finish = new sfn.Pass(this, 'Finish'); + +const definition = choice + .when(condition1, step1) + .otherwise(step2) + .afterwards() + .next(finish); + +map.iterator(definition); ``` ### Custom State