Skip to content

Table of Contents

Introduction

The database and application server are in different networks (VPC). Both VPCs need to communicate with each other and we have three options thats using VPN Connection, Peering Connection and Transit Gateway Connection. We will establish connection between these two VPCs using Transit Gateway. Lets go ahead and set it up.

Transit Gateway Setup

  • Select Transit gateways and click on Create transit gateway.
  • Provide transit gateway name items-tgw and unchecked Default route table association and Default route table propagation.
  • I have unchecked Default route table association and Default route table propagation. Click on Create transit gateway.
  • Wait whiles in Pending state for about two minutes.
  • Transit gateway has been successfully been created and its now in Available state.

Now lets continue by creating Transit Gateway Attachment by selecting items-tgw.

Transit Gateway Attachment

Items Server VPC Transit Gateway Attachment

Let's start by creating servers (ECS) vpc transit gateway attachment.

  • Select Transit gateway attachments
  • Provide transit gateway attachment name items-server-vpc-tgw-attach and select items-tgw.
  • Enable Appliance Mode support and select items-server-vpc.
  • With Subnet IDs in us-east-1a: private-items-server-us-east-1a-tgw, us-east-1b: private-items-server-us-east-1b-tgw and us-east-1c: private-items-server-us-east-1c-tgw then click on Create transit gateway attachment.
  • Create items-server-vpc-tgw-attach

Items Database VPC Transit Gateway Attachment

Let's continue by creating database (RDS) vpc transit gateway attachment.

  • Select Transit gateway attachments
  • Provide transit gateway attachment name items-database-vpc-tgw-attach and select items-database-tgw.
  • Enable Appliance Mode support and select items-database-vpc.
  • With Subnet IDs in us-east-1a: private-items-database-us-east-1a-tgw, us-east-1b: private-items-database-us-east-1b-tgw and us-east-1c: private-items-database-us-east-1c-tgw then click on Create transit gateway attachment.
  • Created Transit Gateway Attachments.

Now that we have successfully created the transit gateway attachments, lets continue by creating the transit gateway route table.

Transit Gateway Route Table

We will continue by creating one Transit gateway route table which will be used by both server (ECS) VPC and database (RDS) VPC. One best practice is having different route table for each and propagating their route to each other. Let's quickly set the transit gateway route table up.

  • Select transit gateway route table and click on Create transit gateway route table.
  • Provide transit gateway route table name items-tgw-rtb and select transit gateway ID (items-tgw).
  • Click on create transit gateway.
  • Wait whiles in Pending state.
  • Now it has shift from Pending state to Available state.

Now that we have successfully create the route table, lets continue to attach our server (ECS) VPC and database (RDS) VPC to it.

Associate Database (RDS) VPC to Transit Gateway Route Table

  • Check items-tgw-rtb -> click Associations -> and Create association
  • Select items-database-vpc-tgw-attach
  • Click on Create association
  • Wait while association is happening
  • items-database-vpc-tgw-attach association is completed and its in Available state.

Associate Server (ECS) VPC to Transit Gateway Route Table

  • Let's create items-server-vpc-tgw-attach association by clicking on Create association
  • Select items-server-vpc-tgw-attach
  • Click on Create association.
  • Wait while association is happening
  • items-server-vpc-tgw-attach association is completed and its in Available state.

Propagate Server (ECS) Transit Gateway Attachment

Now that we have successfully Associated our transit gateway Attachments to items-tgw-rtb, let's continue by propagating the server (ECS) VPC transit gateway attachments to the transit gateway route table as well.

  • Select items-tgw-rtb by checking it.
  • Select items-server-vpc-tgw-attach
  • Click on create propagation
  • Confirmed propagation status is Enabled
  • Click on route to confirm route has been propagated (wait for like about two minutes)
  • Confirmed Route has been propagated successfully.

Propagate Database (RDS) Transit Gateway Attachment

Now that we have successfully propagated the Server (ECS) transit gateway attachments to the transit gateway route table, we will continue by propagating the Database (RDS) VPC transit gateway attachments to the transit gateway route table as well.

  • Select items-tgw-rtb by checking it.
  • Select items-database-vpc-tgw-attach
  • Click on create propagation
  • Confirmed propagation status is Enabled
  • Confirmed Route has been propagated successfully.

Now that we have successfully setup our transit gateway, let's go ahead and setup our route table. We will create a route to route traffic to our transit gateway, route all traffic going from the private subnets to the public internet using the NAT Gateway. Navigate to the route table page to get started.