I've a project with multiple stacks, but with common stacks.ts file.
- My 1 stack creates a VPC
- My 2 stack creates a ECS
Stack vpc.tf
export class stack-vpc extends Stack {
constructor(scope: Construct, id: string, props?: props) {
super(scope, id, props);
new ec2.Vpc(this, 'dev-vpc', {
cidr: "10.0.0.0/16",
vpcName: "dev-vpc"
})
}
}
Stack ecs.tf
export interface Istack-ecs extends StackProps {
vpc: ec2.Vpc;
}
export class stack-ecs extends Construct {
constructor(scope: Construct, id: string, props: Istack-ecs) {
super(scope, id);
new ecs.Cluster(this, "fargate", {
vpc: props.vpc,
clusterName: "test",
enableFargateCapacityProviders: true
});
}
}
Here is the stacks.ts file
const app = new cdk.App();
const vpc = new stack-vpc(app, "Dev_VPC_CF", props);
const ecs = new stack-ecs(app, "Dev_ECS_CF", props);
The vpc is creating without any problem, however once I'm putting an ecs to my stack the cdk gives me the error:
[Error at /stack-ecs] Could not find any VPCs matching {"account":"__--__","region":"eu-central-1",
"filter":{"tag:Name":"stack-vpc","isDefault":"false"},
"returnAsymmetricSubnets":true,
"lookupRoleArn":"arn:aws:iam::__--__:role/cdk-hnb659fds-lookup-role-__--__-eu-central-1"}
cdk.context.json is retrieving correct values from my aws credentials, so I can't blame the authentification, so my problem I need to somehow wait until one stack will give me an output so I can use it in my other stacks