Hi guys, anyone know why this code returns with em...
# general
m
Hi guys, anyone know why this code returns with empty result? I checked the VPC it has correct subnets assignments.
Copy code
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 😞
Copy code
const vpc = awsx.ec2.Vpc.fromExistingIds(name, {
vpcId: props.vpcId, vpcPublicSubnetIds: publicSubnets.ids, });
m
Copy code
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
I've used
Copy code
const vpc = new awsx.ec2.Vpc('appVpc', { vpcId: props.vpcId })
m
thanks guys!