Ask Your Question
0

How can AWS-CDK be used to pass cross-stack references props between stacks in different regions (cross-region)?

asked 2023-03-22 11:00:00 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-10-30 19:00:00 +0000

devzero gravatar image

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:

  1. Define the 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.

  1. Deploy the source stack to create the output value.

  2. 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.

  1. Use the imported value as needed in the destination 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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-03-22 11:00:00 +0000

Seen: 10 times

Last updated: Oct 30 '22