1. Log in to the AWS Console. Choose a consistent region (e.g., us-east-1
or ap-southeast-1
) where you want to create all resources for this workshop. Make note of your selected region as you’ll need to use the same region throughout.
2. In the AWS Console search bar, type VPC
and select VPC from the dropdown, or navigate to Services > Networking & Content Delivery > VPC.
3. In the VPC Dashboard, select Your VPCs from the left navigation panel, then click Create VPC.
4. Configure the VPC settings:
fcj-vpc
10.10.0.0/16
5. Review your settings and click Create VPC.
6. Verify creation: You should see a success message. The new VPC fcj-vpc should appear in your VPC list with the CIDR block 10.10.0.0/16.
We need total of six subnets, each with a specific IP addresses range. AWS preserves five IP addresses of each subnet by default. Therefore, the Usable Host IP Addresses is calculated by subtracting 5 from the Total Host IP Addresses within that subnet.
Subnet name | CIDR | Usable Host IP Addresses |
---|---|---|
fcj-public-subnet-01 | 10.10.0.0/24 | 249 |
fcj-public-subnet-02 | 10.10.1.0/24 | 249 |
fcj-private-subnet-01 | 10.10.16.0/20 | 4089 |
fcj-private-subnet-02 | 10.10.32.0/20 | 4089 |
fcj-db-subnet-01 | 10.10.2.0/24 | 249 |
fcj-db-subnet-02 | 10.10.3.0/24 | 249 |
Why are our private subnets provisioned with a larger IP addresses range compared to the others? This is because the private subnets are designated for hosting the core compute resources of our Amazon ECS cluster, including the Elastic Network Interfaces (ENIs) for Fargate tasks. Since each task is assigned a unique IP address, ensuring a sufficient and larger allocation of IP addresses in these subnets is crucial to support the dynamic scaling requirements of our application.
Our public subnets are designated for public-facing components and services, such as the Elastic Network Interfaces for the Application Load Balancer and a NAT Gateway. These services typically consume fewer IP addresses. Consequently, we can allocate smaller IP address ranges for the public subnets.
Let’s create these subnets.
1. In the VPC Dashboard, select Subnets from the left navigation panel and click Create subnet.
2. Configure the first public subnet:
fcj-public-subnet-01
10.10.0.0/24
3. Scroll down and click Create subnet.
4. Create the second public subnet by clicking Create subnet again and configure:
fcj-public-subnet-02
10.10.1.0/24
5. Scroll down and click Create subnet.
Ensure you’re using different Availability Zones for each subnet to provide high availability across your infrastructure.
1. In the VPC Dashboard, select Subnets from the left navigation panel and click Create subnet.
2. Configure the first private subnet:
fcj-private-subnet-01
10.10.16.0/20
3. Scroll down and click Create subnet.
4. Create the second private subnet by clicking Create subnet again and configure:
fcj-private-subnet-02
10.10.32.0/20
5. Scroll down and click Create subnet.
Private subnets use larger CIDR blocks (/20) to accommodate more IP addresses for ECS Fargate tasks, which each require a unique IP address for scaling.
1. In the VPC Dashboard, select Subnets from the left navigation panel and click Create subnet.
2. Configure the first database subnet:
fcj-db-subnet-01
10.10.2.0/24
3. Scroll down and click Create subnet.
4. Create the second database subnet by clicking Create subnet again and configure:
fcj-db-subnet-02
10.10.3.0/24
5. Scroll down and click Create subnet.
Database subnets are private subnets designed for hosting database instances like RDS. They require subnets in at least two Availability Zones for Multi-AZ deployments and high availability.
Here is what we have created.