VPC(Virtual Private Cloud)
Published: 2022-07-16 06:12:00

A VPC is a **virtual network** dedicated to your AWS account. It is logically isolated from other virtual networks.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/semunl5silqr7pi9flda.png)

### Types of VPC

1. **Default VPC**
       - It is created by AWS when the account is created
       - All the advanced features are provided.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sx8tzbjhxhcoelh1hpwt.png)
 
2. **Custom VPC**
      It is created explicitly with the required features like subnet, NAT, security groups, Internet gateway, route tables, etc.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hqakj20ir83a8pn91hi4.png)
 

### IP address
- It is a logical numerical label assigned as a unique entity to each device in a network. 
- It is used to locate the host in the network through the **Network ID and Host ID** present in the IP address.

IP address had 4 bytes and each byte has 8bit i.e 32 bits(IPv4)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1l6bq771li2pytzp9ow6.png)
The drawback of IPv4 is limited address space to overcome that we have Ipv6.
The internet is undergoing a gradual transition to IPv6.  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7peb9v0dpg36x65fqi66.png)

There are 3 types of IP address
       1. Public IP
       2. Private IP
       3. Elastic IP
[Details of Types of IP Address](https://dev.to/kumarsai21/public-ip-private-ip-elastic-ip-in-aws-166b)

###CIDR(Classless Inter-Domain Routing)
- It helps to reduce the wastage of Ip addresses.
- It also helps to determine how larger is the network.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hbutoy84xg9ijfqltck1.png)
 

##Components of VPC
1. **Internet Gateway(IGT)**: 
     - This is used to connect over the Internet.
     - IGT helps to communicate over the internet using the target in the routing table
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uuco7tdnd593qqwvr1u5.png)
 
2. **NAT Gateways**: 
     - These are **Network Address Translation** gateway that helps to connect the private subnet to the internet through a public IP but the internet cannot access the private subnet.
     - NAT gateway is created in the pubic subnet and it connects to private through route table.
     - Each NAT gateway is created in a specific Availability Zone and implemented with redundancy in that zone.

      ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5ayfomrsmpg2yu1kech.png)

3. **Route Table**: It defines how the traffic is routed between each subnet.
        ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kxf7otuvbn44klp98lax.png)
4. **Subnets**: These are subnetworks. It is a logical sub-division of a large network.

There are two types of subnets:
1. **Private Subnet**: 
      - Resources are not exposed to the outer world.
      - These use **only the private IPs**.
      - These are mainly used for backend purposes like database storage.
2. **Public Subnet**:
      - Resources are exposed to the internet through the Internet gateway.
      - It uses **both public and private IP**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jf9m278frmfyvs39h1ul.png)