Day 27: Configuring a Public VPC with an EC2 Instance for Internet Access

"I'm a 3rd-year Computer Engineering student at Marwadi University with skills in C++, web development (MERN stack), and DevOps tools like Kubernetes. I contribute to open-source projects and share tech knowledge on GitHub and LinkedIn. I'm learning cloud technologies and app deployment. As an Internshala Student Partner, I help others find jobs and courses." now currently focusing on #90DaysOfDevops
Introduction
During Day 27 of the KodeKloud 100 Days of Cloud Challenge, I explored one of the core networking concepts in AWS by creating a Public Virtual Private Cloud (VPC).
Every AWS resource runs inside a network, and understanding how VPCs, subnets, and internet connectivity work is essential for building secure and scalable cloud infrastructure. In this lab, I created a public VPC, configured a public subnet with automatic public IP assignment, and launched an EC2 instance that could be accessed over the internet using SSH.
Why Create a Public VPC?
A Virtual Private Cloud (VPC) allows you to build an isolated network inside AWS where you can launch and manage your resources securely.
Public VPCs are commonly used for hosting resources that need internet access, such as:
Web servers
Bastion hosts
Load Balancers
Public APIs
Development environments
By enabling automatic public IP assignment, every EC2 instance launched inside the subnet can receive a public IP address and communicate over the internet.
Task Requirements
The following AWS resources needed to be configured:
Create a VPC named xfusion-pub-vpc
Create a subnet named xfusion-pub-subnet
Enable Auto-Assign Public IPv4 Address for the subnet
Launch an EC2 instance named xfusion-pub-ec2
Use t2.micro as the instance type
Allow inbound SSH traffic on port 22
Ensure the EC2 instance is accessible from the internet
Step 1: Create a Public VPC
I opened the VPC Dashboard and clicked Create VPC.
The VPC was configured with the following details:
| Setting | Value |
|---|---|
| Name | xfusion-pub-vpc |
| IPv4 CIDR | Default (or as required) |
After reviewing the configuration, I created the VPC successfully.
Step 2: Create a Public Subnet
Inside the newly created VPC, I created a subnet with the following configuration:
Setting | Value |
Name | xfusion-pub-subnet |
VPC | xfusion-pub-vpc |
After creating the subnet, I enabled:
Auto-Assign Public IPv4 Address
This ensures that every EC2 instance launched in this subnet automatically receives a public IP address.
Step 3: Attach an Internet Gateway to the VPC
To allow resources inside the VPC to communicate with the internet, I created an Internet Gateway (IGW) and attached it to the xfusion-pub-vpc.
Without an Internet Gateway, even an EC2 instance with a public IP address cannot send or receive traffic from the internet.
After attaching the Internet Gateway, I verified that its status showed Attached, confirming that it was successfully connected to the VPC.
Step 4: Configure the Route Table
The next step was to update the route table associated with the public subnet.
I added a new route with the following configuration:
| Destination | Target |
|---|---|
| 0.0.0.0/0 | Internet Gateway (IGW) |
This route tells AWS to forward all internet-bound traffic through the Internet Gateway, making the subnet publicly accessible.
After saving the changes, the route became active.
Step 5: Launch an EC2 Instance in the Public Subnet
With the networking configuration in place, I launched a new EC2 instance.
During the launch process, I configured the following:
| Setting | Value |
|---|---|
| Instance Name | xfusion-pub-ec2 |
| Instance Type | t2.micro |
| VPC | xfusion-pub-vpc |
| Subnet | xfusion-pub-subnet |
I also created a Security Group that allowed SSH (Port 22) access so the instance could be accessed remotely.
Step 6: Verify the EC2 Instance Deployment
After launching the instance, I navigated to the EC2 Instances dashboard to verify the deployment.
The instance appeared in the Running state with the correct VPC and subnet configuration, confirming that the infrastructure had been created successfully.
At this point, the EC2 instance was ready for SSH access once the status checks completed.
What I Learned
This lab helped me understand how multiple AWS networking components work together.
Creating a VPC alone doesn't make an EC2 instance publicly accessible. The subnet must assign public IP addresses, and the Security Group must allow the required traffic. All of these configurations work together to enable internet connectivity.
I also learned why VPC design is one of the first steps when building AWS infrastructure, as it defines how resources communicate with each other and with the outside world.
Conclusion
Day 27 provided hands-on experience with AWS networking by creating a public VPC, configuring a public subnet, and launching an internet-accessible EC2 instance.
Although the setup was simple, it introduced several fundamental networking concepts that are widely used in real-world AWS environments. Understanding VPCs, subnets, public IP assignment, and Security Groups is essential for designing secure and scalable cloud architectures.




