What is VPC?
In AWS, a Virtual Private Cloud (VPC) is a dedicated virtual network to your AWS account. It empowers you to deploy AWS resources, like EC2 instances, within a network. With VPC, you gain authority over the network setup, including the ability to choose your IP address range, establish subnets, and configure route tables and network gateways. This capability enables you to construct a segregated segment within the AWS Cloud, where you can deploy AWS resources in a virtual network resembling a conventional network setup often found in on-premises data centers.
Subnets: Subnets are subdivisions of an Amazon VPC's IP address range. In simple language subnets decide how many IP address it can have . Subnets are associated with availability zones (AZs) and provide isolation between resources deployed in different subnets. You can also configure network access control lists (ACLs) at the subnet level to control inbound and outbound traffic.
Internet Gateway: An Internet Gateway is a service of AWS which provides internet access to the VPC . It acts as a gateway between your Amazon VPC and the internet, allowing resources within the VPC to communicate with the internet and vice versa. The IGW enables outbound internet access for resources and supports scenarios such as hosting public-facing web applications.
Route Tables: A route table contains a set of rules (routes) that determine where network traffic is directed within the VPC. Each subnet is associated with a route table, and you can configure the routes to control traffic flow. For example, you can define routes that direct traffic to the IGW for internet access or to virtual private gateways for connectivity to other networks.
Creating VPC Manually
Navigate to the VPC section in the AWS console and click on the "Create VPC" button
Choose the "VPC only" option. Then, specify the VPC name and manually specify the IPv4 CIDR block from above reference.
Now upon clicking on the "Create VPC" and It created successfully-
Next, generate the Internet Gateway and link it to the VPC.
Now, we connected Internet Gateway successfully but it is in Detached state
Select the created Internet Gateway(My-test-IGW01) and click to Attach to VPC
Select the created VPC(My-test-VPC01) and Attach internet gateway
Now, we can see that the internet gateway in Attached state
Navigate to the subsets section in the Virtual private cloud and click on the "Create subnet" button
Now create subnet with the VPC created.
Specify the Subnet name, Availability Zone and IPv4 CIDR block from the above provided reference. The same steps must be followed to create the remaining public and private subnets.
First we create a Public subnet then, click in Add new subnet
In second subnet, creating a Private subnet and then click Create a subnet
Now, you can see that the Public & Private both subnets are created.
Navigate to the Route tables section in the Virtual private cloud and click on the "Create route table" button
Generate a route table for the Public subnets.
Now, you can see that the Route table is created Successfully, click the Subnet associations with the created route table for the Public subnet. then, click "Edit subnet associations" under Subnet associations.
Choose the Public subnet and then click on "Save Associations"
Now, you can see that the successfully Route table associated with Public subnet.
Generate a route table for the Private subnets.
Now, you can see that the Route table is created Successfully, click the Subnet associations with the created route table for the Private subnet. then, click "Edit subnet associations" under Subnet associations.
Choose the Private subnet and then click on "Save Associations"
Now, you can see that the successfully Route table associated with Private subnet.
Now, select Public subnet then, click "Edit Routes"
Under Edit Routes, click "Add route" add internet gateway which we created earlier then click "Save changes"
See in the Resource map under created VPC
Go to the EC2 instance "launch instance"
"Edit" the Network Setting
Modify the network setting, select the VPC and Subnet are created earlier
Now, we can see that the instance is running
Connect to the instance
Now we have successfully connect with EC2 instance under created the VPC.
keep learning keep sharing
Thank you for taking the time to read…….