The current implementation of the Map state in step function has an issue in the validate(), when you try to synth a stack you always get that the iterator is not provided.
I've created a PR that adds a unit test and fixes the problem #4382
packages/@aws-cdk/aws-stepfunctions/test/test.map.ts
"Map state must have a non-empty iterator"
This is :bug: Bug Report
As a temporary workaround I use CfnStateMachine and render definition string manually (using Jinja2 for example)
I don't understand. Since iterator is required in Map and adding iterator does not work, then how were we supposed to use it?
@jeshan It is just a bug, when the #4382 will be merged and released we could use the Map feature
Right! That's why I'm wondering: was it ever usable in 1.12?
no, hoping that PR will be merged before 1.13
same issues faced here.. hoping the PR gets landed soon 馃
Closed by linked PR
I'm still facing this issue with the latest cdk release, creating my stack in python with something like:
from aws_cdk import (
core,
aws_stepfunctions as sfn,
)
class MyTestStack(core.Stack)
def __init__(self, parent, id_, props):
super().__init__(app, id_)
pass_map = sfn.Pass(self, "Map Iterator Pass")
poly_to_tiles_task_map = sfn.Map(
self,
"Polygong2TilesMap",
max_concurrency=0,
)
poly_to_tiles_task_map.iterator(pass_map)
....
but upon a synth I receive the error:
jsii.errors.JSIIError: Validation failed with the following errors:
[yolk-test-stack-large-parcel/Polygong2TilesMap] Map state must have a non-empty iterator
You need to declare an iterator. Here is an example in JavaScript syntax:
let mapState = new Map(this, 'map', {
itemsPath: '$.somePath', // probably optional
})
.iterator({
startState: yourStartTask,
})
.next(someOtherTask);
@jeshan thank you very much. I've tried passing in a dict to the iterator() using the colloquial keys for python - this is what it looks like:
class MyTestStack(core.Stack)
def __init__(self, parent, id_, props):
super().__init__(app, id_)
pass_map = sfn.Pass(self, "Map Iterator Pass")
poly_to_tiles_task_map = sfn.Map(
self,
"Polygong2TilesMap",
max_concurrency=0,
)
poly_to_tiles_task_map.iterator({"start_state": pass_map})
...
I then receive this error:
jsii.errors.JSIIError: Expected object reference, got {"start_state":{"$jsii.byref":"@aws-cdk/aws-stepfunctions.Pass@10047"}}
/private/var/folders/th/2gznbq494d1gxbnbj1215ccc0000gn/T/jsii-kernel-5xp9xO/node_modules/@aws-cdk/core/lib/construct.js:58
throw new Error(`Validation failed with the following errors:\n ${errorList}`);
^
Error: Validation failed with the following errors:
[yolk-test-stack-large-parcel] Map state must have a non-empty iterator
stepfunctions.Pass implements IChainable and should be able to be passed directly like in the test case here: https://github.com/apalumbo/aws-cdk/blob/d67ec09fd0345a821b799c9cb24728d49c5d6b2b/packages/%40aws-cdk/aws-stepfunctions/test/test.map.ts#L47-L59
Any other pointers would be appreciated! edit: and it does, see this comment
I fiddled around with it some more, and discovered that I must chain the .iterator() when I instantiate the Map() like you described @jeshan . This worked enough to synth a template:
pass_map = sfn.Pass(self, "Map Iterator Pass")
poly_to_tiles_task_map = sfn.Map(
self,
"Polygong2TilesMap",
max_concurrency=0,
).iterator(pass_map)
Most helpful comment
You need to declare an iterator. Here is an example in JavaScript syntax: