Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VPC Peering via aws-cdk

I created 2 VPCs using aws-cdk. cdk is creating route tables dynamically when cloudformation stack is created. I created a peering connection between the two VPCs I created using CfnVPCPeeringConnection but I am not sure how to add route to vpc peering connection as I do not know what would be the RouteTableId.

like image 900
Uday Katakam Avatar asked Aug 29 '19 01:08

Uday Katakam


People also ask

How does AWS VPC peering work?

Amazon Virtual Private Cloud (Amazon VPC) enables you to launch AWS resources into a virtual network that you've defined. A VPC peering connection is a networking connection between two VPCs that enables you to route traffic between them using private IPv4 addresses or IPv6 addresses.

What is the difference between VPC peering and VPN?

Functionally, VPC peering is similar to site-to-site VPN, in that it allows communications between two otherwise isolated environments. The biggest difference between VPC peering and site-to-site VPN, however, is that no VPN connection is required.

Does VPC peering cost money?

There is no charge for setting up or running a VPC peering connection. Data transferred across peering connections is charged at $0.01/GB for send and receive, regardless of the Availability Zones involved.


1 Answers

You probably mean the peering connection id. Once you know it you can modify the routing tables.

In typescript, you get it this way

import ec2 = require("@aws-cdk/aws-ec2");
....
const vpc_peering = new ec2.CfnVPCPeeringConnection (...)
const vpc_peering_id = vpc_peering.ref
like image 130
Cristi Lepadatu Avatar answered Sep 22 '22 00:09

Cristi Lepadatu