pulumi / pulumi-awsx

AWS infrastructure best practices in component form!
https://www.pulumi.com/docs/guides/crosswalk/aws/
Apache License 2.0
227 stars 104 forks source link

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

Open aavileli opened 5 years ago

aavileli commented 5 years ago

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

ericrudder commented 5 years ago

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

CyrusNajmabadi commented 5 years ago

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.