I'm trying to get back a VPC and then create a security group with rules in it. I have been following the steps here in their docs however I need to get a vpc that isn't the default vpc.
I have code like so:
const primaryVpcId = config.require("primaryVpcId");
const primaryVpc = awsx.ec2.Vpc.fromExistingIds("primary", {
vpcId: primaryVpcId
});
const sg = new awsx.ec2.SecurityGroup("jcsg", {vpc:primaryVpc});
The problem is the primaryVpc
object is empty so when I run pulumi up
it errors saying the subnet ids are empty. I know there is nothing wrong with the vpc in aws so the retrieving of it is failing somehow.
Based on the docs it looks like when using the fromExistingIds
you have to specify subresource ids as well. If you're planning on using subnets you'll have to pass in the ids for those too they don't appear to be autodiscovered.
Get an existing Vpc resource's state with the given name and IDs of its relevant sub-resources. This will not cause a VPC (or any sub-resources) to be created, and removing this Vpc from your pulumi application will not cause the existing cloud resource (or sub-resources) to be destroyed.
const importedVpc = awsx.ec2.Vpc.fromExistingIds('primary', {
vpcId: 'theId',
privateSubnetIds: ['id1', 'id2']
})
I imagine you'd have to do the same for any of the properties from ExistingVpcIdArgs
(the second parameter to the function) that you plan to use elsewhere in the program.