The specified resource cannot be found in the CDK Stack Export

I'm facing an issue while trying to import values generated and exported from a cdk stack that deploys into eu-west-1 into a different stack that needs to be deployed into af-south-1. The error message states that the export name does not exist:

EU

new CfnOutput(this, 'userPoolArn', {
value: this.userPoolPattern.userPoolArn,})

AF

const userPoolArn = cdk.Fn.importValue('EuWest1Infrastructure:userPoolArn');

Error:

AfSouth1Infrastructure |  0/44 | 20:10:55 | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack            | AfSouth1Infrastructure No export named EuWest1Infrastructure:userPoolArn found. Rollback requested by user.

I have also tried using the value displayed in the console, but it still results in the same error.

Answer №1

Issue 1: When using a CfnOutput, it is important to remember that a cross-stack reference will not be created unless the exportName property is set:

new CfnOutput(this, 'userPoolArn', {
value: this.userPoolPattern.userPoolArn,
exportName: 'UserPoolCrossStackRef', // <--
})

If you are working within a single region, you can then retrieve the value in another stack using

cdk.Fn.importValue("UserPoolCrossStackRef")
.

Issue 2: It's important to note that cross-stack references do not function across different regions:

Documentation: It is not possible to create cross-stack references between regions. The intrinsic function Fn::ImportValue can only import values that have been exported within the same region.

Answer №2

To establish a cross-region cross-stack reference, enable the crossRegionReferences Stack property by setting it to true and then pass the reference between stacks. Below is an illustration from the documentation:

const stack1 = new Stack(app,'Stack1', {
  env: {
    region:'us-east-1',
  },
  crossRegionReferences:true,
});
const cert = new acm.Certificate(stack1, 'Cert', {
  domainName:'*.example.com',
  validation:acm.CertificateValidation.fromDns(route53.PublicHostedZone.fromHostedZoneId(stack1, 'Zone','Z0329774B51CGXTDQV3X')),
});

const stack2 = new Stack(app, 'Stack2', {
  env: {
    region:'us-east-2',
  },
  crossRegionReferences:true,
});
new cloudfront.Distribution(stack2, 'Distribution', {
  defaultBehavior:{
    origin:new origins.HttpOrigin('example.com'),
  },
  domainNames:['dev.example.com'],
  certificate:cert,
});

In this scenario, the cert object is shared among stacks and the necessary cross-region references are automatically established. You can apply the same approach with other resources like UserPool.

Note that this functionality is considered experimental in CDK version 2.114.1

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using TypeScript in conjunction with Node.js

I'm currently trying to use typescript with nodejs, but I keep encountering errors. Can anyone help me troubleshoot? Here is the code snippet (assuming all necessary modules are imported): import routes from "./routes/routes"; let app = express(); ap ...

Encountering a TypeError while working with Next.js 14 and MongoDB: The error "res.status is not a function"

Currently working on a Next.js project that involves MongoDB integration. I am using the app router to test API calls with the code below, and surprisingly, I am receiving a response from the database. import { NextApiRequest, NextApiResponse, NextApiHandl ...

Tip Sheet: Combining Elements from an Array of Objects into a Single Array

When I invoke the function getAllUsers() { return this.http.get(this.url); } using: this.UserService.getAllUsers().subscribe(res => { console.log(res); }) The result is: [{id:1, name:'anna'}, {id:2, name:'john'}, {id:3, name ...

Guide on obtaining Elastic search documents in the specified order of identifiers

Given a specific order of document IDs [1, 4, 2, 5] and some filtering criteria { match: {...} }, what is the most efficient method to ensure that the resulting documents are retrieved in the desired order [1, 4, 2, 5]? Here is an example of a sample docu ...

Guide on incorporating a bespoke cordova plugin into your Ionic 4 project

After successfully completing all the necessary steps to create a new Cordova plugin as outlined in the link below: Start android activity from cordova plugin I executed the command cordova plugin ls which returned the following result: com.example.sam ...

Ways to resolve the issue of incompatible parameters 'action' types in JavaScript

I'm encountering a common problem, but I can't figure out why this error is happening. After updating redux, I encountered the following error message: TS2322: Type '(state: ILanguage | undefined, action: PayloadAction<ILanguage>) =&g ...

An issue arises when trying to utilize meta tags in Nuxtjs while incorporating TypeScript into the

When working with Nuxtjs, I encountered an issue regarding my permissionKeys on the page and checking user access in the middleware. Everything runs smoothly when my script language is set to js, but errors arise when set to lang="ts". I tried to find a s ...

`Incorporate concurrent network requests in React for improved performance`

I am looking to fetch time-series data from a rest service, and currently my implementation looks like this async function getTimeSeriesQuery(i) { // Demonstrating the usage of gql appollo.query(getChunkQueryOptions(i)) } var promises = [] for(var i ...

The variable ApiAIPromises is not recognized within the context of Ionic 3 and Dialogflow

I am currently integrating dialogflow into my ionic app. Below is the code snippet from my .ts file: import { Component, NgZone } from '@angular/core'; import { IonicPage, NavController, NavParams } from 'ionic-angular'; declare v ...

What is the best way to retrieve the current complete URL in a Next.js/Typescript component?

I'm working on a component and I need to retrieve the current full URL. Here's a simplified version of what I have: /** * Share dropdown component */ export const ShareDropdown: React.FC<{ className: string }> = ({ className, }) => { ...

Flying around in every essential element within a Vue template

Recently, I made the switch to Typescript for Vue and decided to enable the Volar extension. However, after doing so, I noticed that every HTML intrinsic element (such as section and img) is now being flagged as an error: JSX element implicitly has type &a ...

Issue with Angular Datatable: Table data is only refreshed and updated after manually refreshing the page or performing a new search query

Having trouble updating Angular Datatable after selecting different data? The API response is coming in but the table data is not being updated. Can anyone suggest how to properly destroy and reinitialize the table for the next click? Below is a snippet ...

Leveraging editor.action.insertSnippet from a different plugin

I am attempting to enhance the functionality of VS Code by adding buttons to the status bar that automatically insert code snippets. I am utilizing this Extension for this purpose. Additionally, I have configured keybindings in my keybindings.json file whi ...

Showing elapsed time similar to YouTube in an Angular 8 application

Currently, I am developing an Angular application to replicate certain features found on YouTube by utilizing data fetched from an API. This API provides video timestamps in a string format Each timestamp follows this structure : YYYY-MM-DDTHH:MM:SS For ...

Exploring the nuances of checking lists in TypeScript

In the following list: empList = ['one','two','finish','one','three'] I am required to evaluate conditions based on empList: Condition 1: If 'two' appears before 'finish', set this ...

What is the best way to modify specific data retrieved from an API using Angular?

After successfully listing some data from an API using ngFor, I am facing an issue with editing the data. Whenever I click the edit button, it edits the entire data instead of just the specific row. Below is the code snippet for reference: HTML <table ...

Encountering a problem when utilizing window.ethereum in Next Js paired with ether JS

Experiencing some difficulties while utilizing the window.ethereum in the latest version of NextJs. Everything was functioning smoothly with NextJs 12, but after upgrading to NextJs 13, this error started popping up. Are there any alternative solutions ava ...

Encountering issue in Angular 14: Unable to assign type 'Date | undefined' to type 'string | number | Date' parameter

I have been working on an Angular 14 project where I am implementing a Search Filter Pipe. Below is the code snippet I am using: import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'transferFilter' }) export class Trans ...

Discovering if the array data is already present in Angular can be accomplished by using specific methods

Here is the snippet of code: data = [ { 'id': 'asdjxv', 'username': 'emma', }, { 'id': 'asqweja', 'username': 'adam', }, { ...

Youngster listens for guardian's occurrence in Angular 2

While the Angular documentation covers how to listen for child events from parents, my situation is actually the opposite. In my application, I have an 'admin.component' that serves as the layout view for the admin page, including elements such a ...