> For the complete documentation index, see [llms.txt](https://gyansetu-aws.gitbook.io/aws-cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gyansetu-aws.gitbook.io/aws-cloud/vpc.md).

# VPC

* Amazon Virtual Private Cloud (Amazon VPC) enables you to launch Amazon Web Services (AWS) resources into a virtual network that you've defined.
* &#x20;VPC is a virtual network dedicated to your AWS account. It is logically isolated from other virtual networks in the AWS cloud
* &#x20;By VPC, we can have complete control over your virtual networking environment, including selection of your own IP address range, creation of subnets, and configuration of route tables and network gateway.
* &#x20;To protect the AWS resources in each subnet, you can use multiple layers of security, including security groups and network access control lists (ACL)

#### &#x20;2 types of VPC

1. &#x20;1\. Default VPC&#x20;
2. &#x20;Custom VPC (nondefault VPC)

#### &#x20;Default VPC

1. &#x20; Default VPC is user friendly, allowing you to immediately deploy instances.&#x20;
2. &#x20;If you have a default VPC and don't specify a subnet when you launch an instance, the instance is launched into your default VPC.&#x20;
3. &#x20;All subnets in default VPC have an internet gateway attached.&#x20;
4. &#x20;Each EC2 instance under VPC have private and public IP address.&#x20;
5. &#x20;If you delete the default VPC only way to get it back is to contact AWS.

#### &#x20;Custom VPC

1. VPC which is created by the user according to the custom configuration is called custom VPC.&#x20;
2. Subnets that you create in your nondefault VPC and additional subnets that you create in your default VPC are called nondefault subnets.

#### &#x20;Subnet

* &#x20;A subnet is a range of IP addresses in your VPC. You can launch AWS resources into a subnet that you select. We can use a public subnet for resources that must be connected to the Internet, and a private subnet for resources that won't be connected to the Internet.

#### &#x20;Route table

* &#x20;A route table contains a set of rules, called routes, that are used to determine where network traffic is directed. Each subnet in our VPC must be associated with a route table, the table controls the routing for the subnet.
* &#x20;A subnet can only be associated with one route table at a time, but we can associate multiple subnets with the same route table.

#### &#x20;Internet gateway

* &#x20;An Internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows communication between instances in your VPC and the Internet.
* &#x20;An internet gateway provides a route out to the internet.&#x20;
* An Internet gateway serves two purposes: to provide a target in your VPC route tables for Internet-routable traffic, and to perform network address translation (NAT) for instances that have been assigned public IPv4 addresses.&#x20;
* For a VPC you can have 1 internet gateway
