Lab: Connect Multiple VPCs with Transit Gateway
Introduction
In this lab, we are going to connect two VPCs via AWS Transit Gateway and adjust route tables to establish private connectivity. This is important, as it will allow communication to flow through your private network without traversing the public internet.
Solution
Log in to the AWS Management Console using the credentials provided on the lab instructions page. Make sure you're using the us-east-1
Region.
Create a VPC
Under Recently visited, select VPC. (If VPC doesn't show up as an option under Recently visited, you can navigate to it by entering vpc in the search bar on top of the console and selecting VPC from the search results.)
Click the Create VPC button.
Under VPC Settings, set the following parameters:
Auto-generate: Make sure the box is checked.
**For the value of the name tag, use project.
IPv4/CIDR block: Enter 172.21.0.0/16 (or anything you want besides the default CIDR block).
Number of Availability Zones: Select 1.
Number of public subnets: Select 0.
Number of private subnets: Select 1
Click the Create VPC button.
Click the View VPC button.
Create Transit Gateway
In the left-hand navigation menu, select Transit gateway.
Click the Create transit gateway button.
Under Name tag, enter Transit.
Click the Create transit gateway button. It may take a minute or two for these to be created.
Attach the Transit Gateway to Both VPCs
In the left-hand navigation menu, select Transit gateway attachments.
Click the Create transit gateway attachments button.
On the Create transit gateway attachment page, set the following parameters:
Name tag - optional: Enter Attachment-1.
Transit gateway ID: Select the Transit gateway that you created earlier.
VPC ID: Select the first VPC option corresponding to 10.0.0/16.
Subnet ID: Check ONLY the first subnet listed (us-east-1a). Uncheck the other Subnet IDs.
Click the Create transit gateway attachment button.
While the first attachment is creating, click the Create transit gateway attachment button.
On the Create transit gateway attachment page, set the following parameters:
Name tag - optional: Enter Attachment-2.
Transit gateway ID: Select the Transit gateway that you created earlier.
VPC ID: Select the second VPC option corresponding to 172.21.0.0/16 (or the CIDR block that you entered earlier when creating the VPC).
Click the Create transit gateway attachment button.
Edit Route Tables
Once both transit gateway attachments are showing as Available, go to the left-hand navigation menu and select Route tables.
From the list of route tables, select the project-rtb-private1-us-east-1a route table ID. (If you don't see it in the route table list, wait a couple of minutes and then hit the refresh button.)
Click the Edit routes button.
Click the Add route button.
For the new route, in the Destination column, enter 10.0.0.0/16.
In the Target column, select Transit Gateway.
When it locates the transit gateway associated with Attachment-2, select that gateway.
Click the Save Changes button.
In the breadcrumb trail on top of the page, select Route tables.
Select the route table ID that has three subnets associated with it.
Click the Edit routes button.
Click the Add route button.
For the new route, in the Destination column, enter 172.21.0.0/16 (or the CIDR block that you entered earlier when creating the VPC).
In the Target column, select Transit Gateway.
When the transit gateway associated with Attachment-1 is located, select that gateway.
Click the Save Changes button. Now, both subnets are able to communicate with each other.
Last updated
Was this helpful?