VPC Fundamentals
This section introduces the core concept of Amazon Virtual Private Cloud (VPC), its foundational role within AWS, and essential attributes.
A Virtual Private Cloud (VPC) is a logically isolated section of the AWS Cloud that allows you to launch AWS resources into a virtual network that you define. It provides you with more control over your network environment compared to using AWS resources without a VPC. This isolation enhances security and control over your network resources. VPCs are virtual data centers in the cloud that allow you to define your own network with complete control over virtual networks, IP address ranges, subnets, route tables, and network gateways. (source_page: 1, 2)
Amazon VPC is a virtual network within the AWS cloud that provides a logically isolated section for deploying and managing AWS resources. It allows you to create a customizable virtual network, offering greater control and security than the default VPC. This isolation ensures better security and resource management. (source_page: 1)
VPCs are regional resources, meaning a VPC spans all the Availability Zones in a region. (source_page: 2, 3)
By using VPC, you can have more control over your network architecture, including IP address range, subnets, and routing tables. VPCs can leverage multiple layers of security including security groups and network access control lists to control access to EC2 instances in each subnet. You can create hardware virtual private network connections between your corporate data center and your VPC to leverage the AWS cloud as an extension of your corporate data center. You can launch instances into a subnet of your choosing, create custom IP address ranges for each subnet, configure route tables between subnets, and attach an Internet gateway to your VPC. (source_page: 2, 4)
AWS creates a default VPC (172.31.0.0/16) when you create an account. This includes an internet gateway, a default route table, and public subnets in each Availability Zone with auto-assign public IP enabled. The default VPC is user-friendly and has all subnets with a route out to the Internet. (source_page: 1, 2, 4)
Custom VPCs are fully customizable but take more time to set up. Creating additional VPCs provides good advantages from a security perspective. (source_page: 2, 4)
IP Addressing and CIDR
This section covers the fundamentals of IP addressing within a VPC, including CIDR notation, private and public IP ranges, and AWS-reserved IP addresses.
When creating a VPC, you must specify a primary CIDR block (a range of IP addresses) and a region. It is critical to use non-overlapping IP address ranges within your VPCs and between VPCs. Adhere to RFC 1918 standards for private IP addresses to avoid conflicts with public IP addresses. You can add up to four secondary CIDR blocks to a VPC. (source_page: 1, 2, 4)
Technical Specs: Valid RFC 1918 private IP ranges: 10.0.0.0/8 (Class A), 172.16.0.0/12 (Class B), and 192.168.0.0/16 (Class C).
Primary CIDR block size: /16 to /28 for IPv4 VPCs. (source_page: 1, 3, 4)
Maximum IP address ranges per VPC: 5 (1 primary, 4 secondary). (source_page: 2)
CIDR notation (x.x.x.x/n) specifies an IP address range. The 'x.x.x.x' represents the IP address, and '/n' denotes the number of bits in the network prefix. For IPv4, 'n' ranges from 0-32. The larger the 'n' value, the smaller the address range, as fewer bits are available for defining host addresses. Conversely, the smaller the '/xx' number, the larger the IP address range, as more bits are available for defining the IP address range. (source_page: 1, 4)
Technical Specs: IPv4 network prefix bits: 0-32. (source_page: 1)
AWS reserves the first four IP addresses and the last IP address in each subnet CIDR block for network, router, DNS server, future use, and broadcast addresses. This means five IP addresses are lost from a traditional network block. (source_page: 2, 4)
Private IP addresses are used within private networks, such as Amazon Virtual Private Clouds (VPCs) or local area networks (LANs). They are not publicly routable from the internet. Every EC2 instance receives at least one private IP address upon launch, which is static and persists even after restarts, facilitating internal communication within the VPC. Each instance must have a primary private IP address from the range specified by the subnet CIDR. You can't change or remove this address, but you can assign secondary private IP addresses to the primary ENI from the same subnet. (source_page: 1, 2, 7, 10)
Public IP addresses are used for resources that need to be accessible from the internet and are routable globally. While an EC2 instance can be assigned a public IP for external access (requiring it to be in a public subnet or have auto-assign public IP enabled), these addresses are dynamic and change if the instance is stopped and started. (source_page: 5, 7, 10)
Elastic IP Addresses (EIPs) are static, public IPv4 addresses allocated to your AWS account. An EIP can be associated with an EC2 instance and reattached to another if needed, providing a consistent public IP that doesn’t change upon instance restart. When an EIP is associated, it replaces any existing public IP on the instance. While useful for legacy applications, for modern, stable applications, alternatives like DNS names or Load Balancers are generally preferred over EIPs for achieving a stable public presence. (source_page: 1, 5, 7, 10)
Technical Specs: IPv6 support: Not supported for EIPs (IPv4 only). (source_page: 4, 7, 10)
Quota: AWS accounts typically have a soft limit of 5 EIPs per region, which can be increased. (source_page: 2, 7, 10)
Cost: EIPs are charged by AWS regardless of whether they are associated with a resource or remain idle. (source_page: 7, 10)
AWS VPC also supports IPv6 addressing. All IPv6 addresses are public, there are no private address ranges available on IPv6 for you to use with AWS. AWS chooses the IPv6 CIDR block for your VPC, you cannot choose that yourself. (source_page: 1, 4)
Technical Specs: IPv6 format: 128-bit (8 groups of 4 hexadecimal digits). (source_page: 4)
VPC CIDR block size fixed at /56. (source_page: 1, 4)
Subnet CIDR block size fixed at /64. (source_page: 1, 4)
Elastic IPv6 addresses: Not supported. (source_page: 4)
To change the IP range of an existing VPC or subnet (e.g., /24 to /20), you must terminate that existing VPC and create a new one. You can expand an existing VPC by adding up to four secondary IPv4 address ranges to that VPC. You can shrink your VPC by deleting those secondary CIDR blocks at any time. You cannot change the size of an IPv6 address range on your VPC. (source_page: 4)
VPC Configuration Procedures
procedure
Configuring a VPC involves a series of steps to define its network space, segment it into subnets, and establish routing rules. The following outlines general and specific procedures mentioned in the source material.
VPC Connectivity Options
AWS provides a rich set of services to connect your VPC to the internet, other VPCs, on-premises networks, and AWS services, addressing various architectural needs from basic internet access to complex hybrid cloud environments.
VPC Quotas and Limits
Understanding the default quotas and limits for VPC resources is essential for planning and scaling your network architecture within AWS.
AWS imposes default soft limits on various VPC resources, which can often be increased upon request.
Technical Specs: VPCs per Region: 5 (source_page: 2)
Subnets per VPC: 200 (source_page: 1, 2)
IPv4 & IPv6 CIDR blocks per VPC: 5 (source_page: 2)
NACLs per VPC: 200 (source_page: 2)
Rules per NACL: 20 (source_page: 2)
VPC Security Groups per region: 2,500 (source_page: 2)
Inbound and Outbound Rules per Security Group: 60 (source_page: 2)
Elastic IPs per region: 5 (source_page: 2)
Elastic IPs per public NAT Gateway: 2 (source_page: 2)
Egress-only Internet Gateways per Region: 5 (source_page: 2)
Internet Gateways per Region: 5 (source_page: 2)
NAT Gateways per AZ: 5 (source_page: 2)
Minimum subnet size for IPv4: /28 (allows 11 available IP addresses). (source_page: 1, 4)
Maximum IP address ranges per VPC: 5 (1 primary, 4 secondary). (source_page: 2)
Maximum IP addresses per subnet: 2048. (source_page: 2)
Maximum route tables per VPC: 200. (source_page: 2)
Maximum rules per security group: 500. (source_page: 2)
Maximum security groups per VPC: 500. (source_page: 2)