AWS Transit Gateway Peering 2 VPCs in different AWS Regions
Tags: aws, networking, beginners, community
Published: 2023-07-18 12:52:03

A transit gateway is a network transit hub that you can use to interconnect your virtual private clouds (VPCs) and on-premises networks. As your cloud infrastructure expands globally, inter-Region peering connects transit gateways together using the AWS Global Infrastructure.

Enabling peering between multiple VPCs on AWS can be difficult. It can be much more difficult if they are in different regions.

Here is digram about **AWS VPC Peering** vs. **AWS Transit Gateway**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9z25elundiezp1zdv3b.png)

I will walk you through the process of enabling peering between multiple VPCs.

I have 2 VPCs and Subnet information.   

**US East 1**: 10.1.0.0/16 - 3 Public & 3 Private subnets /20
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cbylzgxeiazg2giu59zo.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sibxmt2yz13jx5kw5kt6.png)

**US West 2**: 10.2.0.0/16 - 3 Public & 3 Private subnets /20
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8blwyxqm2604n74ddvvy.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r1bzrjpa5mo3rog9j3al.png)

Two Route tables each VPC.  Public route table is using Internet Gateway to access outside and private route table has just local.  Here are their screenshots

**US East 1 Region**:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3kwpwm2ewi5jy7hzlw9.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s74vtonml3c3qh23223y.png)

**US West 2 Region**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z407vyoyqvnlk3cbcyfh.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sxv3yby6a4joj8p9xljx.png)

Also I created Two EC2 instances each region. One public instance and one private instance.  I am going to use Ping, ssh & telnet as my test cases using private ip addresses. 

**US East 1 Region** 

- Create Transit Gateway with unique ASN: TGW-US-East-1-TG1 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pc6p7hlzjc253er5igkd.png)

- Create Transit Gateway Attachment: TGW-US-East-1-VPC and select all available subnets. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ve5zswe9cw9jm7bgx7ai.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0kdq1f98ozj14qdgxxg7.png)

- Verify Transit Gateway Route tables (Make sure there is entry at Propagations & Routes tabs

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z1n9f8hc7rf3b0lmejx7.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rxly5uioa4q54uhu4rvr.png)

- Update Route Tables (both Public & Private Route tables) at US East 1 VPC. Add recently created Transit Gateway with US West 2 VPC CIDR address 10.2.0.0/16
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iv92pvffvm2ji81zxytv.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/98eys4xmmh14u5bv574a.png)

- Copy US East 1 Transit Gateway ID & Save somewhere:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hdy2hgtk3u26g3xxtya5.png)

**US West 2 Region**

- Create Transit Gateway with unique ASN: TGW-US-West-2-TG2
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9w06iggupzvg6ogzrd0e.png)

- Create Transit Gateway Attachment: TGW-US-West-2-VPC and select all available subnets. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sh809dp7e2r3404wse66.png) 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p1m1kguu529kqvaaogxx.png)

- Update Route Tables (both Public & Private Route tables) at US West 2 VPC. Add recently created Transit Gateway with US East 1 VPC CIDR address 10.1.0.0/16 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rnzx7y5g6e7ulldgnxta.png) 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t05v3bf6bao8xkrxxb83.png)

- Create Transit Gateway attachment Peering Connection at US West 2 region (Need to paste US East 1 region Transit Gateway ID - copied from earlier step) 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9k8d7wle31qvwewpi5l.png)

- Sent Peering request to US East 1 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bkg3zpo8jjjx59trzrrb.png)

- At **US East 1 Region** Accept Peering request 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/axwo5qcztnjzj2jj8kwj.png)

- After 20 minutes Peering was available 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uu3281bn9isnhab9f8as.png)

- Back to Transit Gateway route tables under Transit Gateway and create static route

- At US East 1 Region Transit Gateway route tables add US West 2 CIDR 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjqzqm1gzlp5yaknbqi8.png)

- Click "Create static route" enter US West 2 CIDR and choose Peering type 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fjesqjgu8k094jqa5hwz.png)

- At US West 2 Region Transit Gateway route tables add US East 1 CIDR 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9sku97wvvl8ye1ded65w.png)

- Click "Create static route" enter US East 1 CIDR and choose Peering type 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nmx05eu7kpi7wvjtfs61.png)

**US East 1 Region EC2 service**

- Security group for EC2 instance.  Didn't open for anywhere 0.0.0.0/16.  Just opened for US West 2 VPC/CIDR at inbound rules 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hv25h7o6nd2vwgrnkp7g.png)

- From _US East 1_ Region EC2 instance Ping/SSH/Telnet using _US West 2_ Region EC2 instance's **_private ip address (successful)_**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vknogo5i0ejxrsqughzt.png)

- From _US West 2_ Region EC2 instance Ping/SSH/Telnet using _US East 1_ Region EC2 instance's **private ip address (successful)**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/as5i8kp3l3334qfm7brg.png)

Now we are successfully peered two VPCs (different regions) using AWS Transit Gateway method.  

Here is solution digram 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/no2r2f5byio0uc88aeha.jpg)

**_Clean up hint_**: Shutdown or terminate ec2 instances, delete security group, delete transit gateway attachments from both regions (vpc & peering) then delete transit gateway from both regions. _

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1gajq1aus30lf8zdyovp.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bac9916sk4oexxnfyo6m.png)