aws_stepfunctions: addPrefix fails when added to map iterator
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When using `StpeFunctionFragment` construct with map, `prefix_states()` method does not workg properly with `Map` construct used in fragment.
This feels like `add_prefix` would add prefix only to CDK constructs but not to the step function tasks inside MAP iterator elements. Issue does not exist outside of the map.
_Note_: worth to check if `Parallel` is not affected as well.
### Expected Behavior
Create `Map` element iterator items with proper prefix.
### Current Behavior
Prefix feels not to be added at proper time instant, erroring with duplicated states. The error for code example below is:
```jsii.errors.JSIIError: State with name 'The Pass' occurs in both Map The Map Iterator (Fragment 1: The Pass) and Map The Map Iterator (Fragment 2: The Pass). All states must have unique names.```
### Reproduction Steps
Minimum viable code to reproduce error:
```import aws_cdk as cdk
from aws_cdk import (
aws_stepfunctions as sfn,
Stack,
)
from constructs import Construct
class HasMapIssueFragment(sfn.StateMachineFragment):
def __init__(self, parent, fragment_id: str) -> None:
super().__init__(parent, fragment_id)
map = sfn.Map(
self,
"The Map",
).iterator(
sfn.Pass(self, "The Pass")
)
self._start_state = map.start_state
self._end_states = map.end_states
self.prefix_states(f'{fragment_id}: ')
@property
def start_state(self) -> sfn.State:
return self._start_state
@property
def end_states(self) -> list[sfn.INextable]:
return self._end_states
class HasMapIssue(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
machine = HasMapIssueFragment(self, "Fragment 1").next(HasMapIssueFragment(self, "Fragment 2"))
self.step_function = sfn.StateMachine(
self, "The Machine",
state_machine_type=sfn.StateMachineType.STANDARD,
definition=machine,
)
app = cdk.App()
HasMapIssue(app, "HasMapIssueStack",)
app.synth()
```
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.54.0
### Framework Version
_No response_
### Node.js Version
v18.12.1
### OS
OSX
### Language
Python
### Language Version
Python 3.9.6
### Other information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.