Add Transit Gateway Routes to VPC Route Tables

Add Transit Gateway Routes to VPC Route Tables

In this section, you will configure route table at each VPC to route traffic to the remaining VPCs through Transit Gateway.

  1. Open VPC Management Console, select Route Tables in the left sidebar. We stipulate that:

    • First VPC Main Route Table = Route Table of VPC1
    • Second VPC Main Route Table = Route Table of VPC2
    • Third VPC Main Route Table = Route Table of VPC3
    • Fourth VPC Main Route Table = Route Table of VPC4

Result

  1. With Route Table of VPC1, select Edit routes.

Result

  1. Add route with the following parameters:
  • Destination: 172.16.0.0/16
  • Target: select the Transit Gateway you created.

Result

  1. This tells VPC1 that all packets for any 172.16.x.x network go through Transit Gateway.

Result

  1. With VPC3’s Route Table, select Edit routes.

Result

  1. Add a route with the following parameters:
  • Destination: 172.16.0.0/16
  • Target: select the Transit Gateway you created.

Result

  1. This tells VPC3 that all packets for any 172.16.x.x network go through the Transit Gateway.

Result

  1. Similar to Route Table of VPC2, select Edit routes.

Result

  1. Add route with the following parameters:
  • Destination: 0.0.0.0/0
  • Target: select Transit Gateway you created

Result

  1. This tells VPC2 that all packets for any network other than the local network pass-through Transit Gateway.

Result

  1. Similar to Route Table of VPC4, select Edit routes.

Result

  1. Add a route with the following parameters:
  • Destination: 0.0.0.0/0
  • Target: select Transit Gateway you created

Result

  1. This tells VPC4 that all packets for any network other than the local network pass-through Transit Gateway.

Result

Thus, you have completed the configuration to allow the four VPCs to communicate with each other through Transit Gateway. Let’s check if the EC2 instances from VPC1 and VPC3 can connect to the EC2 instances in VPC2 and VPC4!

Check the result.

  1. Connect SSH to EC2 instance at VPC1 and authenticate you can ping www.amazon.com for authentication and check the internet connection.
ping amazon.com -c5

Result

  1. Ping to the IP of EC2 instance in VPC2.

Result

  1. View details EC2 instance in VPC2
  • Select Connect

Result

  1. Select SSH client and see the connection steps.

Result

  1. Using the Key Pair you copied to the instance in the previous section, connect SSH from EC2 instance at VPC1 to EC2 instance at **VPC2 ** with commands:
  • Grant permissions to the keypair file with the following command:
chmod 400 <keypairname.pem>
  • Perform SSH into EC2 with the following command:
ssh -i "<YourKey.pem>" ec2-user@<YourEC2IP>

Result

  1. In turn, ping the IP Private address of the EC2 instance at VPC3.

Result

  1. In turn, ping the IP Private address of the EC2 instance at VPC4.

Result

Congratulations!!! The EC2 Instances in your VPCs were able to connect through the Transit Gateway.