sparse-spring-91820
11/05/2021, 3:46 PMA
I created a VPC like this:
const vpc = new awsx.ec2.Vpc('project-a-vpc', { numberOfAvailabilityZones: 2 });
module.exports = { vpcId: vpc.id };
and inside project B
I created Vpc resource pointing to existing Vpc like this:
const stack = new pulumi.StackReference('myorg/stack-a/main');
const vpcId = mainStack.getOutput('vpcId');
const vpc = new awsx.ec2.Vpc('vpc', { vpcId });
But when I try to use the publicSubnetIds property it says it is an empty array, but inside stack A, it is not empty.
const dbSubnetGroup = new aws.rds.SubnetGroup('db-subnet-group', {
subnetIds: vpc.publicSubnetIds
});
Any clue how can I refer to an existing vpc and use all its properties as I would inside project A?
Also, if I go with this solution of getting existing vpc:
const vpc = aws.ec2.Vpc.get('vpc', vpcId);
i dont have publicSubnetIds
property at all.witty-candle-66007
11/05/2021, 4:05 PMvpc-id
in the filter.sparse-spring-91820
11/05/2021, 4:10 PMwitty-candle-66007
11/05/2021, 4:16 PMsparse-spring-91820
11/05/2021, 4:18 PMmodule.exports = {
publicSubnetIds: pulumi.output(vpc.publicSubnetIds)
}
const publicSubnetIds = mainStack.getOutput('publicSubnetIds');
const dbSubnetGroup = new aws.rds.SubnetGroup('db-subnet-group', {
subnetIds: publicSubnetIds
});
witty-candle-66007
11/05/2021, 5:01 PMpublicSubnetIds
stack output is read in as an object and so needs to be processed a bit before being used in subnetgroup declaration.
In stackB if you do something like
module.exports = {
publicSubnetIdsFromA: pulumi.output(mainStack.getOutput("publicSubnetIds"))
}
you’ll see the subnet IDs made it over to stack b.
But to use them as in the subnetgroup declaration requires some type casting or something (that I haven’t figured out yet).const stackA = new pulumi.StackReference("MitchGerdisch/quick-test/dev")
const pulumiSubnetIdsFromA = pulumi.output(stackA.getOutput("pulumiSubnetIds"))
const dbSubnetGroup = new aws.rds.SubnetGroup('db-subnet-group', {
subnetIds: pulumiSubnetIdsFromA
});
pulumi.output()
bit:
const stackA = new pulumi.StackReference("MitchGerdisch/quick-test/dev")
const pulumiSubnetIdsFromA = stackA.getOutput("pulumiSubnetIds")
const dbSubnetGroup = new aws.rds.SubnetGroup('db-subnet-group', {
subnetIds: pulumiSubnetIdsFromA
});
sparse-spring-91820
11/05/2021, 6:40 PMwitty-candle-66007
11/05/2021, 6:45 PM