Introducing Today's Project!
Today, we are going to build an AWS VPC from scratch and understand how the different components work together. We will create a VPC, configure public and private subnets, set up routing and an Internet Gateway,get practical knowledge of cloudshell, and launch resources to test connectivity. The goal is to gain practical experience designing and managing a basic cloud network.
Virtual Private Clouds (VPCs)
What I did in this step
In this step, we are creating the VPC, which will serve as our private network inAWS. We will define its IP address range and establish the foundation for theother resources we will add later.
How VPCs work
A VPC (Virtual Private Cloud) is a private, isolated network within AWS where we can create and manage cloud resources such as EC2 instances, databases, andother services. It is a private network inside AWS, where you control the IP addresses, subnets, routing, and security.
Why there is a default VPC in AWS accounts
The default VPC is automatically created by AWS so we can start launching resources immediately without having to build a network from scratch. It provides basic networking components like subnets, route tables, and an internet gateway.
Defining IPv4 CIDR blocks
To set up my VPC, I had to define an IPv4 CIDR block. An IPv4 CIDR block is away of defining a range of IPv4 addresses that can be used within a network. For example, 10.0.0.0/24 defines a network containing a range of IP addresses. In AWS, CIDR blocks are used to determine the IP address range for a VPC or subnet.
Subnets
What I did in this step
In this step, I am creating a subnet inside the VPC and assigning it a specific IP address range. This gives us a smaller network where we can place and manage resources such as EC2 instances.
Creating and configuring subnets
Subnets are smaller networks created inside a VPC. They divide the VPC's IP address range into separate sections, allowing you to organize resources andcontrol how they communicate. For example, a VPC could have a public subnet for web servers and a private subnet for databases.
Public vs private subnets
For a subnet to be considered public, it has to have an internet gateway attached to it. Until we attach an internet gateway to the public subnet, it is only public by name but does not yet perform the public function.
Auto-assigning public IPv4 addresses
You enable auto-assign public IPv4 addresses so resources launched in thatsubnet can automatically receive a public IP address and communicate with theinternet. This is commonly used for public subnets where resources like webservers need to be accessible from the internet.
Internet gateways
What I did in this step
In this step, we shall attach an internet gateway to our VPC
An Internet Gateway (IGW) is a component that connects your VPC to the public internet. It allows resources in a public subnet, such as an EC2 instance with a public IP, to send and receive internet traffic.
Attaching an Internet Gateway (IGW) to the VPC creates a path between the VPC and the public internet. However, resources still need a public IP address and a route through the Internet Gateway to actually access the internet.
Using the AWS CLI
What I'm doing in this extension
In this mission, I am using AWS CloudShell and the AWS CLI to build the network infrastructure without relying entirely on the AWS Console. I will create a VPC,subnet, and Internet Gateway using commands.
Exploring CloudShell and CLI
AWS CloudShell is a browser-based terminal provided by AWS where you can run commands directly within your AWS environment without installing anything on your computer. CLI (Command Line Interface) is a way of interacting with AWSservices by typing commands instead of clicking through the AWS Console.
Debugging my setup
I ran into the error because my VPC was 10.0.0.0/24, but tried to create a subnetusing 10.0.1.0/24. 10.0.1.0/24 is outside the VPC's IP range, so AWS rejected it.The subnet's CIDR block must always fall within the VPC's CIDR range.
Comparing CloudShell vs AWS Console
Setting up VPC resources in CloudShell using the AWS CLI is faster and more efficient for repetitive tasks because you can create resources with commands and easily automate the process. The AWS Console is more visual and beginner-friendly, making it easier to understand the relationships between VPC components. For learning, the Console helps with visualization, while CloudShell is better for practicing real-world automation and command-line skills.





Top comments (0)