https://pulumi.com logo
Title
v

victorious-fountain-7689

10/21/2021, 5:23 AM
Hi! In Pulumi crosswalk for AWS, is it possible to get the complete
awsx.ec2.Vpc
object using
awsx.ec2.Vpc.fromExistingIds
? Eventhough I passed in
vpcId
,
publicSubnetIds
and
privateSubnetIds
, the output of
.getSubnets("public")
seems to be an empty list.
I think that it is handled in the code here, but not sure when it is called. When I debugged it, I could not trace the
super()
call.
b

billowy-army-68599

10/21/2021, 5:29 AM
hey there, not sure I'm following. You have an existing VPC, and you're using
awsx.ec2.Vpc.fromExistingIds
and you passed in the subnet ids, and now you want to grab the subnets from the
const vpc = awsx.ec2.Vpc.fromExistingIds
right? is there a reason you wouldn't just get the subnets from the
publicSubnetIds
you already passed in?
v

victorious-fountain-7689

10/21/2021, 5:35 AM
Hi! My goal there is to grab the associated route table IDs and create a route in them to do VPC peering. Since
awsx.ec2.Subnet
has a
routeTable
attribute, it was an easy task. I was wondering if I could do the same with the
awsx.ec2.Vpc
object created using
awsx.ec2.Vpc.fromExistingIds
b

billowy-army-68599

10/21/2021, 5:38 AM
i don't believe it can be done with
fromExistingIds
no, because that particular method only populates the vpc itself, not the res of the resources inside the component (I think)
v

victorious-fountain-7689

10/21/2021, 5:39 AM
Yeah, it is working like that. However, when I looked in the source code of
awsx.ec2.Vpc
, I found some populating code. Not sure when it gets called
The easy way would be to export route table IDs from other stack, and use it while creating peering connection, in that case.
m

miniature-advantage-31279

10/23/2021, 5:27 AM
heya, I am having the same issues, it seems you have to set it manually
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,
    });
🙌 1
hopefully @billowy-army-68599 can verify this whether it is true?
b

billowy-army-68599

10/23/2021, 12:41 PM
that looks correct to me
🙌 1
v

victorious-fountain-7689

11/01/2021, 2:10 PM
@miniature-advantage-31279 Thanks for the solution, for a quick testing, I exported the
publicSubnetIds
and
privateSubnetIds
from other stack and using
awsx.ec2.Vpc.fromExistingIds
. Unfortunately, that seemed not populating
routeTables
properties of
awsx.ec2.Subnet
instances. Ultimately, I ended up exporting
routeTableIds
itself from another stack 😅
m

miniature-advantage-31279

11/01/2021, 3:19 PM
yeah that also alternative that I did
v

victorious-fountain-7689

11/02/2021, 4:08 AM
Ah, okay 👍