VPC with a single Public Subnet

Ashwin Morey
3 min readOct 24, 2020

--

In this article we will see steps to create a custom VPC with a single public subnet. We will create this architecture without using VPC wizard. It is suitable for single tier applications such as blog or a simple website.

We will have this architecture setup by the end of this article. So, lets look into it step by step.

Create a VPC
In the create VPC section provide a VPC name and a valid CIDR address. Keep the other settings as it and hit create VPC button. We can optionally provide tags to uniquely identify the VPC.

AWS Management Console Create VPC

Once the VPC is created, a default route table is also created with it. This the default Main Route table for the VPC.

Create Internet Gateway
In the Create Internet Gateway section provide name for the internet gateway. Once created, we need to attach it to the VPC created above. IGW is responsible for routing traffic from resources with VPC to the public internet.

AWS Management Console Create Internet Gateway
AWS Management Console attach IGW

Create a Public Subnet
Next, we move on to create a subnet in the VPC. Provide name and select VPC created above in the VPC dropdown. Also, provide a valid CIDR block for the subnet, 10.0.0.0/24 in our case. The subnet is by default associated with the Main Route table. But we will create a separate route table and associate newly created subnet with it.

AWS Management Console create subnet

Create Route Table
In the create route table section provide name and select VPC created above from the VPC dropdown.

AWS Management Console Create Route Table

We will then associate our subnet with this route table. Under the Subnets Associations tab click on the Edit Subnet associations button, select newly created subnet and hit save button.

Next, add a route table entry to the Internet Gateway created above. Under the Routes tab click on Edit Routes button. Then add 0.0.0.0/0 route against the internet gateway and hit save routes button. Coming back on route table dashboard we should be able to see this entry. This means that all the traffic to the public internet from resources inside the subnet, will go through the Internet Gateway. A subnet is called a Public subnet, because route table associated with the subnet has an entry to the Internet Gateway.

In the last step we will update Modify auto-assign public IP settings for the subnet we created. This will auto assign IPV4 public address to any EC2 instance launched in this subnet by default.

With this we are done creating infrastructure for our architecture. To test if the resources created within our public subnet is able to access the internet, launch an EC2 instance in public subnet.The EC2 instance will have a Public IPV4 address associated with it. Next, SSH into the EC2 instance and ping google.com. It should work.

--

--

Ashwin Morey
Ashwin Morey

Written by Ashwin Morey

0 Followers

I am 2x AWS Certified Professional and 1x Oracle certified java associate. I love coding and I am passionate about writing on latest technical stuff.

No responses yet