pulumi-awsx icon indicating copy to clipboard operation
pulumi-awsx copied to clipboard

Add method to get all sub resources of a vpc in awsx package

Open aavileli opened this issue 5 years ago • 2 comments

Can we get another method called fromExistingVpcId on awsx.ec2.vpc class so we don't need to specify all the subresource ids like a data block. This is so silly if the vpc was created using the awsx package you have already set the public, private and isolated subnets with included tags

aavileli avatar Aug 13 '19 02:08 aavileli

Cyrus, this is the one we just chatted about ...

ericrudder avatar Aug 13 '19 23:08 ericrudder

This is doable, but definitely non-trivial. Many of the resources we make are not necessarily tagged with any sort of information to know how they were created. We would have to reinfer this stuff. At a minimum it would involve:

  1. walking all subnets to figure them out, and filtering down to only the ones we tag in our current manner.
  2. walking all IGs to find those associated with this VPC id.
  3. walking the subnets to figure out the routetable and routetableassociation info.
  4. figuring out hte association between subnets and IGs in those tables.
  5. findin the natgateways and eips, figuring out which correpond here based on the routing tables.

The idea here was that the information would be fairly easy to export if needed. For example, you really only need to export 6 values from your Vpc, and then use those to rehydrate the Vpc later on. We could make it easier to get the ExistingVpcIdArgs from an actual Vpc. That way you could just export that for your stack and then read that in later.

CyrusNajmabadi avatar Aug 20 '19 23:08 CyrusNajmabadi