https://pulumi.com logo
Title
m

miniature-advantage-31279

10/23/2021, 3:20 AM
Hi guys, anyone know why this code returns with empty result? I checked the VPC it has correct subnets assignments.
const vpc = awsx.ec2.Vpc.fromExistingIds(name, { vpcId: props.vpcId });
console.log(await vpc.publicSubnetIds);
However if I create a new vpc, it will return the correct public subnet IDs, it seems there is missing initialisation internally if we are using fromExistingIds?
it seems, it is required to set the public and private subnet manually 😞
const vpc = awsx.ec2.Vpc.fromExistingIds(name, {
vpcId: props.vpcId, vpcPublicSubnetIds: publicSubnets.ids, });
m

millions-furniture-75402

10/23/2021, 5:35 PM
const publicSubnets = await aws.ec2.getSubnetIds({
      vpcId: vpcId,
      filters: [{ name: 'tag:type', values: ['public'] }],
    });
    const privateSubnets = await aws.ec2.getSubnetIds({
      vpcId: vpcId,
      filters: [{ name: 'tag:type', values: ['private'] }],
    });

awsx.ec2.Vpc.fromExistingIds(name, {
      vpcId: vpcId,
      publicSubnetIds: publicSubnetIds,
      privateSubnetIds: privateSubnetIds,
    });
b

broad-gold-44713

10/23/2021, 6:19 PM
I've used
const vpc = new awsx.ec2.Vpc('appVpc', { vpcId: props.vpcId })
m

miniature-advantage-31279

10/25/2021, 1:52 PM
thanks guys!