Created
May 13, 2021 15:04
Revisions
-
statik created this gist
May 13, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ // Given a pre-existing VPC network layout with stable ID, subnets, and routing tables // this CDK setup code will populate the context necessary for lookups without going // through synth and maintaining the context cache outside of version control private setupFooVpcContext(): void { // this is the CDK context info for the Demo VPC in the example account const account = "1234" const region = "us-west-2" const tag = "MyDemoVPC" const contextKey = `vpc-provider:account=${account}:filter.tag:Name=${tag}:region=${region}:returnAsymmetricSubnets=true'; const contextData = { vpcId: 'vpc-TODO', availabilityZones: [], subnetGroups: [ { name: 'Public', type: 'Public', subnets: [ { subnetId: 'subnet-TODO', availabilityZone: 'us-west-2a', routeTableId: 'rtb-TODO', }, { subnetId: 'subnet-TODO', availabilityZone: 'us-west-2b', routeTableId: 'rtb-TODO', }, ], }, ], }; this.node.setContext(contextKey, contextData); } // then you can use code like const vpc = Vpc.fromLookup(this, 'AVPC', { vpcName: 'MyDemoVPC', });