Fix error: cannot consume a cross reference from stack in AWS CDK


The error Error: Stack "exampleStack1" cannot consume a cross reference from stack "exampleStack2". Cross stack references are only supported for stacks deployed to the same environment or between nested stacks and their parent stack likely happens if you do the following:

  1. You try to reference another stack that is in a different AWS region. Note: cross region references aren’t supported.
  2. You aren’t passing region and account values in the env of the StackProps.

In order to fix the error in AWS CDK, you need to add the env with region and account parameters to the stack when you create it as shown in the code example below:

new exampleStack1(
  app, 'exampleStack1', {
    env: {
      region: 'eu-west-1',
      account: '012345678910',
    },
  });
}


Danny Steenman

A Senior AWS Cloud Engineer with over 9 years of experience migrating workloads from on-premises to AWS Cloud.

I have helped companies of all sizes shape their cloud adoption strategies, optimizing operational efficiency, reducing costs, and improving organizational agility.

Connect with me today to discuss your cloud aspirations, and let’s work together to transform your business by leveraging the power of AWS Cloud.