Table of Contents
Introduction
We will create Public and Private Subnets for items-server-vpc and items-database-vpc. Three (3) Availability Zones (Az) will be used for this project hence we will create one subnet in each Az (us-east-1a, us-east-1b, us-east-1c).
ECS Subnet
We will create three public subnet (will use one subnet for Nat Gateway), three private subnet for Transit Gateway, three private subnet for ECS EC2 Instances and three private subnet for ECS Service.
Private EC2 Subnet
We will first create the Private EC2 Subnets. The EC2 instances part of the ECS Cluster will be deployed in this subnet.
- Select Subnet and click on Create subnet
- Select items-server-vpc
- Provide subnet name private-items-server-us-east-1a-ec2, select availability zone us-east-1a and CIDR 10.0.0.0/24. Click on Add new subnet to add the next subnets.
- Provide the second subnet name private-items-server-us-east-1b-ec2, select availability zone us-east-1b and CIDR 10.0.1.0/24. Click on Add new subnet to add the next subnets.
- Provide the last subnet name private-items-server-us-east-1c-ec2, select availability zone us-east-1c and CIDR 10.0.2.0/24. Click on Create subnet to create the subnet.
- Here are all the three subnets which got created.
Private Transit Gateway Subnet
We will continue by creating the Private Transit Gateway Subnets in each Availability Zones (us-east-1a, us-east-1b and us-east-1c).
- Select Subnet and click on Create subnet
- Select items-server-vpc
- Provide subnet name private-items-server-us-east-1a-tgw, select availability zone us-east-1a and CIDR 10.0.3.0/24. Click on Add new subnet to add the next subnets.
- Provide subnet name private-items-server-us-east-1b-tgw, select availability zone us-east-1b and CIDR 10.0.4.0/24. Click on Add new subnet to add the next subnets.
- Provide subnet name private-items-server-us-east-1c-tgw, select availability zone us-east-1c and CIDR 10.0.5.0/24. Click on Create subnet to create the subnet.
- Here are all the three subnets which got created.
Private ECS Service Subnet
We will continue by creating the Private ECS Service Subnets in each Availability Zones (us-east-1a, us-east-1b and us-east-1c).
- Select Subnet and click on Create subnet
- Select items-server-vpc
- Provide subnet name private-items-server-us-east-1a-service, select availability zone us-east-1a and CIDR 10.0.6.0/24. Click on Add new subnet to add the next subnets.
- Provide subnet name private-items-server-us-east-1b-service, select availability zone us-east-1b and CIDR 10.0.7.0/24. Click on Add new subnet to add the next subnets.
- Provide subnet name private-items-server-us-east-1c-service, select availability zone us-east-1c and CIDR 10.0.8.0/24. Click on Create subnet to create the subnet.
- Here are all the three subnets which got created.
Public Subnet
We will continue by creating the Public Subnets in each Availability Zones (us-east-1a, us-east-1b and us-east-1c). Application Load Balancer (ALB) will be deployed in this subnets. Aside that we will deploy NAT Gateway in one of these public subnets which will be in us-east-1a.
- Select Subnet and click on Create subnet
- Select items-server-vpc
- Provide subnet name public-items-server-us-east-1a, select availability zone us-east-1a and CIDR 10.0.9.0/24. Click on Add new subnet to add the next subnets.
- Provide subnet name public-items-server-us-east-1b, select availability zone us-east-1b and CIDR 10.0.10.0/24. Click on Add new subnet to add the next subnets.
- Provide subnet name public-items-server-us-east-1c, select availability zone us-east-1c and CIDR 10.0.11.0/24. Click on Create subnet to create the subnet.
- Here are all the three subnets which got created.
Database Subnet
Now that Server (ECS) VPC has been created, we will continue by setting up subnets for our database. One batch of subnet will be used by RDS subnet group while the other will be used by transit gateway attachment.
Private RDS Subnet
We will now create Subnets for RDS. These subnets will be deployed in us-east-1a, us-east-1b and us-east-1c availability zone to enable high availability for the RDS.
- Select Subnet and click on Create subnet
- Select items-database-vpc
- Provide subnet name private-items-database-us-east-1a-rds, select availability zone us-east-1a and CIDR 10.1.0.0/24. Click on Add new subnet to add the next subnets.
- Provide the second subnet name private-items-database-us-east-1b-rds, select availability zone us-east-1b and CIDR 10.1.1.0/24. Click on Add new subnet to add the next subnets.
- Provide the last subnet name private-items-database-us-east-1c-rds, select availability zone us-east-1c and CIDR 10.1.2.0/24. Click on Create subnet to create the subnet.
- Here are all the three subnets which got created.
Private RDS Transit Gateway Subnet
Last batch of subnet we will create are transit gateway subnet for RDS. Since we will be using transit gateway to establish communication between RDS VPC and Server (ECS) VPC, we will have to create these subnets.
- Select Subnet and click on Create subnet
- Select items-database-vpc
- Provide subnet name private-items-database-us-east-1a-tgw, select availability zone us-east-1a and CIDR 10.1.3.0/24. Click on Add new subnet to add the next subnets.
- Provide the second subnet name private-items-database-us-east-1b-tgw, select availability zone us-east-1b and CIDR 10.1.4.0/24. Click on Add new subnet to add the next subnets.
- Provide the last subnet name private-items-database-us-east-1c-tgw, select availability zone us-east-1c and CIDR 10.1.5.0/24. Click on Create subnet to create the subnet.
- Here are all the three subnets which got created.
Now that we have successfully setup all subnets for both rds vpc and server (ecs) vpc, we will continue by setting up our internet gateway.