In this lesson, you will learn how to convert a private subnet into a public subnet so that any EC2 instance deployed within becomes accessible from the Internet. We will create a VPC, a subnet, and then attach an Internet Gateway—all from scratch.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
Create a VPC
First, log into the AWS Management Console and navigate to the VPC page. Create a new VPC using the IPv4 CIDR block 10.0.0.0/16. (Assigning an IPv6 CIDR block is optional for this exercise.)
Create a Subnet
Next, create a subnet within the newly created VPC. Name this subnet “public subnet” and assign it the CIDR block 10.0.1.0/24.

Launch an EC2 Instance
- Open the EC2 page in a new tab and click on Launch Instance.
- Name the instance (e.g., “my public server”) and select the Amazon Linux AMI.
- Choose the default instance type (t2.micro – covered by the free tier) and select an existing key pair for SSH access.






Both the
ping and ssh commands will hang or time out because the subnet is private and lacks the necessary Internet routing configuration.Attach an Internet Gateway
To enable Internet connectivity, you must create and attach an Internet Gateway to your VPC.- Return to the VPC page and click on the Internet Gateway section.
- Create a new Internet Gateway and give it a name (e.g., “my-internet-gateway”).
- Attach the newly created Internet Gateway to your VPC.


ping command to confirm the connection still fails.
Update the Route Table
Next, update the route table to direct traffic destined for the Internet through the Internet Gateway. Follow these steps:- Check the subnet’s route table using the “Route Table” tab in the VPC console. You will notice that only a local route exists.
- Edit the default route table or create a new custom route table (e.g., “public route table”) associated with your VPC.
- Associate the route table with the public subnet.
- Add a default route (0.0.0.0/0) that directs all Internet-bound traffic to the Internet Gateway.

It may take a few moments for the new routing configuration to propagate.