Skip to content

Commit

Permalink
docs(step-functions): add multi state example for map state
Browse files Browse the repository at this point in the history
  • Loading branch information
anshikam committed Aug 25, 2023
1 parent c67da83 commit b4c62e9
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion packages/aws-cdk-lib/aws-stepfunctions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b4c62e9

Please sign in to comment.