Skip to content

fix: "duplicate Export names" error deploying nested stacks with Fn::Join exports#1307

Merged
aws-cdk-automation merged 5 commits intomainfrom
mrgrain/fix/toolkit-lib/nested-stacks-fn-join-duplicate-exports
Apr 3, 2026
Merged

fix: "duplicate Export names" error deploying nested stacks with Fn::Join exports#1307
aws-cdk-automation merged 5 commits intomainfrom
mrgrain/fix/toolkit-lib/nested-stacks-fn-join-duplicate-exports

Conversation

@mrgrain
Copy link
Copy Markdown
Contributor

@mrgrain mrgrain commented Apr 3, 2026

CDK CLI v2.1116.0 added IncludeNestedStacks: true to the deploy changeset creation path (PR #1292). This tells CloudFormation to validate all nested stack templates together when creating a changeset.

However, CloudFormation cannot resolve intrinsic functions at changeset validation time. When multiple nested stacks use Fn::Join (or similar intrinsics) to build export names with runtime references, CloudFormation collapses all of them to the same placeholder {{IntrinsicFunction://Fn::Join}} and reports a false "duplicate Export names" error. This affects patterns like the Amplify GraphQL API construct which uses Fn::Join with an API ID to generate unique export names across nested stacks.

This PR removes IncludeNestedStacks from the deploy changeset path, reverting to the pre-v2.1116.0 behavior. The diff changeset path (cdk diff --method=change-set) retains IncludeNestedStacks since --method=auto (the default) already falls back to template-based diff on error, and changeset diff didn't work for any nested stacks in previous versions so the current behavior is strictly an improvement.

Internal reference D423570178


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

mrgrain added 2 commits April 3, 2026 14:22
…oin exports\n\nWhen IncludeNestedStacks is true, CloudFormation collapses all Fn::Join\nexport names to {{IntrinsicFunction://Fn::Join}}, causing a false\nduplicate export name error when multiple nested stacks have Fn::Join\nexports with runtime references.
…eation\n\nCloudFormation cannot resolve intrinsic functions (like Fn::Join) in\nexport names at validation time when IncludeNestedStacks is true. It\ncollapses all such exports to the same placeholder, causing a false\n\"duplicate Export names\" error.\n\nReverts the IncludeNestedStacks addition from the deploy changeset path.\nThe diff changeset path retains it since --method=auto already falls\nback to template-based diff on error.
@mrgrain
Copy link
Copy Markdown
Contributor Author

mrgrain commented Apr 3, 2026

Internal reference: D423570178

@mrgrain mrgrain changed the title fix(toolkit-lib): false "duplicate Export names" error deploying nested stacks with Fn::Join exports fix: false "duplicate Export names" error deploying nested stacks with Fn::Join exports Apr 3, 2026
@mrgrain mrgrain changed the title fix: false "duplicate Export names" error deploying nested stacks with Fn::Join exports fix: "duplicate Export names" error deploying nested stacks with Fn::Join exports Apr 3, 2026
…stedStacks in deploy path"

This reverts commit 7409264.
…tedStacks

The --force deploy assertion expected CloudFormation to report "no
changes" for nested stacks, which only works with IncludeNestedStacks.
Without it, CloudFormation always executes the changeset for nested
stacks. Update the assertion to expect a new changeset instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants