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

feat(core): add Fn::GetStackOutput for cross-region references#37724
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

Resolving the security guardian violation in the integ.pipeline-with-replication integ test is a bit more involved, as we can't hard-code SourceArn and SourceAccount conditions, as this may change by environment. I'm sure there is some clever way to do this, but I'd rather leave this as a follow-up.

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 1, 2026

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
Copy link
Copy Markdown
Contributor

mergify Bot commented May 1, 2026

Merge Queue Status

  • Entered queue2026-05-01 17:08 UTC · Rule: default-squash
  • Checks passed · in-place
  • Merged2026-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
Copy link
Copy Markdown
Contributor

mergify Bot commented May 1, 2026

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
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

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