Skip to content

Conversation

Kasra-G
Copy link
Contributor

@Kasra-G Kasra-G commented Sep 4, 2025

Issue #

Closes #35391.

Reason for this change

When the only instances of DistributedMap states were inside nested StateGraphs (most commonly reported as Parallel branches, see #28820), StateGraph.bind would fail to find these DistributedMaps and thus fail to add the necessary DistributedMap policies to the state machine's execution role. This means the state machine execution would fail as soon as it got to the nested DistributedMap state.

This was originally included in #34760, but aligned that it should go into its own PR #34760 (comment)

Description of changes

This change allows DistributedMap states in any level of nested StateGraphs to be discovered and considered for the DistributedMap policy additions.

Changes:

  • Does a BFS of all nested StateGraphs when calling the root StateGraph's bind() method to find DistributedMap states
  • DistributedMap states inside Parallel branches now add distributed map policies to the state machine as expected

The idea of recursing through state graphs can be attributed to #29913, but to avoid the recursion, I just converted the logic to use a loop.

Describe any new or updated permissions being added

State machines with a DistributedMap state inside a Parallel branch will now receive the proper policy for execution (Documented here: https://docs.aws.amazon.com/step-functions/latest/dg/iam-policies-eg-dist-map.html#iam-policy-run-dist-map)

Description of how you validated changes

Unit & new Integ test that deploys and runs a StateMachine with a DistributedMap inside a Parallel state.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team September 4, 2025 16:01
@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/medium Medium work item – several days of effort p2 labels Sep 4, 2025
@Kasra-G Kasra-G marked this pull request as ready for review September 4, 2025 16:36
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Sep 4, 2025
@Kasra-G Kasra-G changed the title fix(stepfunctions): unable to run distributed map when none are defined in top level state graph fix(stepfunctions): unable to run distributed map when only defined in nested StateGraphs Sep 4, 2025
@kumvprat kumvprat self-assigned this Sep 5, 2025
Copy link
Contributor

@kumvprat kumvprat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your continued contribution on this @Kasra-G

Added a comment inline

@Kasra-G

This comment was marked as resolved.

@Kasra-G Kasra-G force-pushed the ft/step-functions/distributed-map-nested branch from fddcaa1 to 4d35364 Compare September 5, 2025 19:03
@Kasra-G Kasra-G force-pushed the ft/step-functions/distributed-map-nested branch from 4d35364 to ceb1685 Compare September 5, 2025 19:32
Copy link
Contributor

mergify bot commented Sep 9, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Copy link
Contributor

mergify bot commented Sep 9, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 036b413 into aws:main Sep 9, 2025
19 checks passed
Copy link
Contributor

github-actions bot commented Sep 9, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/medium Medium work item – several days of effort p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stepfunctions: DistributedMaps cannot be run if they are not declared in top level StateGraph
3 participants