To pass cross-stack references props between stacks in different regions (cross-region) using AWS-CDK, you can use the CfnOutput
construct in the source stack to output the value you want to pass to the destination stack, and then use the CfnImportValue
construct in the destination stack to import the output value.
Here are the general steps to follow:
CfnOutput
that will output the value in the source stack:const output = new CfnOutput(this, 'OutputName', {
value: 'outputValue',
exportName: 'exportName'
});
Note that the exportName
parameter is used to specify a unique name for the exported value.
Deploy the source stack to create the output value.
In the destination stack, use the CfnImportValue
construct to import the value:
const importedValue = Fn.importValue('exportName');
The importedValue
variable will now contain the value that was output by the source stack.
Note that both stacks must have the necessary permissions to import and export values to and from the AWS CloudFormation stack exports and exports tables.
Asked: 2023-03-22 11:00:00 +0000
Seen: 10 times
Last updated: Oct 30 '22