CloudFormation supports the concept of exporting outputs from one stack and importing their values into another stack.
Here's a blog post that illustrates this concept in further detail.
Note that neither CDK nor CloudFormation support circular stack dependencies, so you can't have stack A depend on a resource in stack B while also having stack B depend on a resource in stack A. The stack dependency graph must be acyclical.
CDK can handle export/import of the resource variable automatically.
If you make a resource a member variable of the stack instance, and reference that stack member variable from the other stack by passing the variable as a property of stack props parameter, CDK will export the resource reference, and import it from the other stack automatically.
You can find more detailed information from https://docs.aws.amazon.com/cdk/v2/guide/resources.html#resource_stack.
Be aware that this operation only supported in a same region stacks. If you need to deploy the two stacks in two different regions, you need other mechanism.
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated a year ago
- EXPERTpublished 2 months ago