There were no VPCs found that matched the criteria in the AWS CDK search

I've been attempting to integrate a non-default VPC into my CDK application, but I'm encountering difficulties with the vpc.fromLookup function. Despite providing filters and setting the environment account and region in the stack, I keep receiving an error stating "Could not find any VPCs matching". I've double checked the VPC ID and Name, both of which are correct. Any assistance would be greatly appreciated as I am still learning AWS and CDK.

I've also attempted using tagName or VPCId separately, but the same error persists.

[Error at /MyStack] Could not find any VPCs matching {"account":"00000000","region":"ca-central-1","filter":{"tag:aws-cdk:subnet-type":"private","vpc-id":"vpc-00000000","tag:Name":"vpc","isDefault":"false"},"returnAsymmetricSubnets":true} Found errors

const vpc = ec2.Vpc.fromLookup(this, "VPC", {  vpcName: vpcName,  isDefault: false,
       vpcId: vpcId, tags: { "aws-cdk:subnet-type": "private" }, 
});

env: {
 account: process.env.CDK_DEPLOY_ACCOUNT || process.env.CDK_DEFAULT_ACCOUNT,
 region: process.env.CDK_DEPLOY_REGION || process.env.CDK_DEFAULT_REGION, 
},

Thank you for your assistance!

Answer №1

After successfully resolving the issue at hand, I discovered that the root cause was due to BastionHostLinux being incorrectly set as a Public subnetType. This resulted in an error message stating "There are no '${subnetType}' subnet groups in this VPC", leading me to believe that I needed to add tags to my VPC. Adding the necessary tags did resolve the initial error, but then I encountered another issue of "Could not find any VPCs matching...". It became clear that I should not solely rely on error messages...

As a solution, I made the following change:

const vpc = ec2.Vpc.fromLookup(this, "VPC", {
  vpcId: vpcId,
  isDefault: false,
});

Following this adjustment, the VPC was successfully imported without any issues.

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

Unexpected behavior with HashLocationStrategy

I am currently tackling a project in Angular2 using TypeScript, and I seem to be having trouble with the HashLocationStrategy. Despite following the instructions on how to override the LocationStrategy as laid out here, I can't seem to get it to work ...

Angular Typescript Controller's Constructor not being invoked

I have been working with Angular using TypeScript. Here is my model class in TypeScript: module app.form { export class Patient{ constructor( public firstName: string, public lastName: string, public gend ...

Prevent Promise / Property not found error in Angular2 by Instantiating Class

When working with my "export class", I encountered an issue that led to a Promise error if I didn't include this line of code: purchase = new Purchase(); right before the constructor. The error indicated that the property "name" was not found. Alth ...

Unable to retrieve mongoose Schema context while using Typescript

I am attempting to use the functions .pre, .method, and .static with my Mongoose Schemas. The code I have written seems to be causing issues, as my understanding of Schemas or the context of this may be incorrect. export interface IUser extends mongoose. ...

Guide on clearing a form after it has been submitted with Controller As syntax

Once a user submits an object through a form, I want the form to reset so they can add another entry. I've attempted to use $setPristine() but am struggling with the syntax. Currently, I have resorted to redirecting back to the same page, which doesn& ...

Angular - Error: Attempted to access property 'nodeName' of null

I recently updated many dependencies in my project that is based on a newly released theme version. Despite fixing compiler issues, I now face the following error: Error: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'nodeN ...

Utilizing a custom function declared within the component to handle changes in Angular's ngOnChanges

Although it may seem like a simple question, I'm struggling to find a solution. Here's the issue at hand: In my Angular Component, there's a function that I need help with. export class RolesListComponent implements OnInit, OnChanges { ...

The Error message "Property 'data' is not present in Type <void> | AxiosHttpResponse<any>" is indicating that the data property is missing on

When I fetch data for a specific user, I have a promise that I use to setState. Below is the implementation: getUserUsername = (): string => { const { match } = this.props; return match.params.username; }; onFetchUser = () => getUse ...

I keep encountering the following error message: " ERROR Error Code: 200 Message: Http failure during parsing for http://localhost:3000/login"

My Angular Login component is responsible for passing form data to the OnSubmit method. The goal is to send form data from the front-end application and authenticate users based on matching usernames and passwords in a MySQL database. ***This login form i ...

Error: The specified property is not found on the object in Ionic TypeScript

I am facing an issue while trying to define a todo object that stores members' usernames and passwords with data fetched using ngmodel. Despite my efforts, I have not been able to successfully initialize this object. I attempted to utilize arrow notat ...

The value of "x" cannot be altered, yet it remains unrestricted

In my Angular 10 project with Typescript 3.9, I have the following class definition: export class Document { constructor( public id: number, ... public tags: Tag[] ) { this.id = id; ... this.tags = ta ...

Is it possible to implement a page transition using preact?

I've been experimenting with creating a page transition using preact-router. I attempted to use the preact-transition-group package along with the preact-css-transition-group package, but encountered an error. Despite this, here is my basic setup: imp ...

Updating the dropdown option value in Angular 10's edit component

In my Angular and ASP.NET application, I have an edit form in a component with multiple select options in a dropdown list. When displaying all data in the edit form, the dropdown list fields are displayed as empty instead of showing the previously stored v ...

UI components displaying varying data retrieved from Redux, despite having identical user interfaces

Currently, I have a component that receives data from the Redux store using useSelector. The UI remains the same, but I need to change where the data is coming from by passing the selector through props. My first question is: Is it acceptable to pass the ...

How to convert DateTime to UTC in TypeScript/JavaScript while preserving the original date and time

Consider the following example: var testDate = new Date("2021-05-17T00:00:00"); // this represents local date and time I am looking to convert this given Date into UTC format without altering the original date and time value. Essentially, 2021-0 ...

Encountering an issue when attempting to establish a connection to cockroachdb using the geography datatype in type

Encountering an error while attempting to connect to Cockroach DB with a 'geography' column: Unable to connect to the database: DataTypeNotSupportedError: Data type "geography" in "Club.latlon" is not supported by "cockro ...

Encountering difficulties importing in Typescript and ts-node node scripts, regardless of configuration or package type

I am facing a challenge with my React Typescript project where multiple files share a similar structure but have differences at certain points. To avoid manually copying and pasting files and making changes, I decided to create a Node script that automates ...

Warning: Google Map API alert for outdated Marker Class

Working on an application using the Google Maps TypeScript API, I came across a warning message when launching the app -> As of February 21, 2024, google.maps.Marker will no longer be available. Instead, developers are advised to use google.maps.marke ...

NextJS - The server attempted to execute the find() function, which is only available on the client side

When attempting to utilize the .find method within the server component, I encounter an error. export async function TransactionList() { const transactions = await fetch('/transactions'); return ( <ul> {transactions.m ...

Attempting to create distinct match matchups for every team in a manner reminiscent of the Swiss system format used in the 2024/25 UEFA Champion League

I've been working on devising a tournament pairing system modeled after the updated UEFA Champion League structure. The league phase involves 36 teams, categorized into 4 different pots. Each team is scheduled to play a total of 8 matches against 2 op ...