feat(core): add Fn::GetStackOutput for cross-region references by otaviomacedo · Pull Request #37724 · aws/aws-cdk · GitHub
Skip to content

feat(core): add Fn::GetStackOutput for cross-region references - #37724

Merged
mergify[bot] merged 46 commits into
mainfrom
otaviom/native-cross-region-references
May 1, 2026
Merged

mergify[bot] merged 46 commits into
mainfrom
otaviom/native-cross-region-references

Conversation

@otaviomacedo

Copy link
Copy Markdown
Contributor

By default, the CDK only allows references between resources if they are in the same environment (account and region). But users can opt in to an experimental feature that allows cross-region, same-account references, by setting the crossRegionReference flag to true in the consumer stack. With this feature on, when there is a cross-region reference, the CDK generates two custom resources that communicate with each other via SSM parameters. A writer resource is deployed to the producer stack, and a reader resource is deployed to the consumer stack.

So far, this was the best mechanism to "export" a value in the producer and "import" it in the consumer. But CloudFormation has now released a new intrinsic function, Fn::GetStackOutput, which, as the name suggests, gets the value of a arbitrary output. This function works cross-region and cross-account. This PR introduces support for these two use cases.


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

Introduces a new feature flag `USE_GET_STACK_OUTPUT` that enables using
the CloudFormation intrinsic function `Fn::GetStackOutput` for cross-region
stack references instead of custom resources with SSM parameters.

When `crossRegionReferences=true` and this flag is enabled, cross-region
references are resolved using `Fn::GetStackOutput`, which directly retrieves
outputs from other stacks without requiring custom resources.

Changes:
- Add `Fn.getStackOutput()` method and `FnGetStackOutput` class in cfn-fn.ts
- Implement `createGetStackOutput()` in refs.ts to generate outputs and references
- Add `USE_GET_STACK_OUTPUT` feature flag with recommended value `true`
- Update feature flags documentation and recommended flags configuration
- Add test coverage for the new functionality
Comment thread packages/aws-cdk-lib/README.md
@aws-cdk-automation
aws-cdk-automation dismissed their stale review May 1, 2026 15:19

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@otaviomacedo

Copy link
Copy Markdown
Contributor Author

@mergify

mergify Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

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 commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-05-01 17:08 UTC · Rule: default-squash
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-05-01 17:38 UTC · at f5c2c48e37f3a16822c4ca1247153dc51a186b53 · squash

This pull request spent 29 minutes 37 seconds in the queue, including 29 minutes 19 seconds running CI.

Required conditions to merge

@mergify
mergify Bot temporarily deployed to automation May 1, 2026 17:09 Inactive
@mergify
mergify Bot temporarily deployed to automation May 1, 2026 17:09 Inactive
@mergify

mergify Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

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 ffae861 into main May 1, 2026
21 of 24 checks passed
@mergify
mergify Bot deleted the otaviom/native-cross-region-references branch May 1, 2026 17:38
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 1, 2026

This branch was previously deployed

1 inactive deployment
automation — f5c2c48e Deployed May 1, 2026 by mergify[bot] via validate-pr #343300
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

contribution/core This is a PR that came from AWS. p2 pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants