VPC
Last updated
Last updated
Amazon Virtual Private Cloud (Amazon VPC) enables you to launch AWS resources into a virtual network that you've defined. This virtual network closely resembles a traditional network that you'd operate in your own data center, with the benefits of using the scalable infrastructure of AWS.
Inside this virtual network, you can deploy AWS computing resources. These resources include, for example, Amazon Elastic Compute Cloud (Amazon EC2) or Amazon Relational Database Service (Amazon RDS) instances.
You can spin up a logical environment of what was previously in a data center within minutes in the cloud.
It is more cost-effective than maintaining equipment in a company data center.
You pay for only the resources that you use.
It’s secure, scalable, and reliable.
You can create multiple Amazon VPCs for testing, owning customer accounts, and more.
When you create a VPC, you must specify the IPv4 address range by choosing a CIDR block, such as 10.0.0.0/16.
An Amazon VPC address range could be as large as /16 (65,536 addresses) or as small as /28 (16 addresses).
Private IP ranges should be used according to RFC 1918.
IP addresses should not overlap with the addresses of other networks to which an Amazon VPC is connected.
Private address range:
10.0.0.0–10.255.255.255
10.0.0.0/16
172.16.0.0–172.31.255.255
172.31.0.0/16
192.168.0.0–192.168.255.255
192.168.0.0/16
A VPC can span multiple Availability Zones, and its key component types include:
Amazon VPC: It is a logically isolated environment for your resources within the cloud. You can choose a Region here.
Internet gateway: An internet gateway is a VPC component that enables communication between instances in a VPC and the internet.
Subnet: Subnets are logical network segments within your VPC. They enable you to subdivide your VPC network into smaller networks inside a single Availability Zone.
One subnet per Availability Zone because a subnet cannot span zones.
Public Subnet: A public subnet is associated with a route table that has a route to an internet gateway.
Private Subnet: A private subnet does not have an internet gateway on the route table that is associated to it. However, a NAT gateway can be a route on this route table.
AWS reserves the first four IP addresses and the last IP address of every subnet for internal purposes.
Example:
10.0.0.0
Network address
10.0.0.1
VPC router
10.0.0.2
Domain Name System (DNS) server
10.0.0.3
Reserved for future use
10.0.0.255
Network broadcast
Route Table: A route table holds the route and target information required to route traffic within the Amazon VPC.
There are destinations and targets. Destinations hold IP addresses and ranges, and targets hold a service.
Each route table must be associated to a subnet.
A route table associates the subnet and gateways together.
Security group: A security group is a set of firewall rules that secure instances.
They allow or block inbound and outbound traffic into an instance.
Security groups are stateful.
Stateful means that if requests from your instance are sent, the response traffic is allowed to flow back regardless of the inbound rules.
A security group blocks all traffic by default; you must allow the protocol, port range, Internet Control Message Protocol (ICMP) type, and source or destination.
If you do not specify a particular group at launch time, an instance is automatically assigned to the default security group for the VPC.
A security group is associated with an instance.
Network Access Control List (NACL): It acts as a firewall at the subnet level.
NACL are stateless.
Stateless means you seperately have to allow both request and response.
Network ACLs have separate inbound and outbound rules.
Each rule can either allow or deny traffic by increments of 10 or 100.
Difference between Security Groups & NACL:
Operates at the instance level
Operates at the subnet level
Supports allow rules only
Supports allow & deny rules
Stateful
Stateless
Evaluates all rules
Process rules in order
Applies to an instance only if associated
Automatically applies to all instances in
Primary network interface (elastic network interface): An elastic network interface is a virtual network interface (NIC) that connects an instance to a network.
Each instance in a VPC has a default network interface, the primary network interface, which cannot be detached from the instance.
Network Address Translation (NAT) Gateway: A NAT gateway permits instances in the private subnet to connect outside the VPC
The NAT gateway is assigned an Elastic IP address, which is a public IP address and is located in the public subnet.
IP addressing: You can assign IPv4 addresses and IPv6 addresses to your VPCs and subnets. You can also bring your public IPv4 and IPv6 GUA addresses to AWS and allocate them to resources in your VPC, such as EC2 instances, NAT gateways, and Network Load Balancers.
Note: You can only define VPCs with CIDR blocks of /16 through /28 inclusive, which means that a VPC can contain 16 – 65,536 IP addresses.
Routing: Use route tables to determine where network traffic from your subnet or gateway is directed.
Gateways and endpoints: A gateway connects your VPC to another network. For example, use an internet gateway to connect your VPC to the internet. Use a VPC endpoint to connect to AWS services privately, without the use of an internet gateway or NAT device.
Peering connections: Use a VPC peering connection to route traffic between the resources in two VPCs.
Traffic Mirroring: Copy network traffic from network interfaces and send it to security and monitoring appliances for deep packet inspection.
Transit gateways: Use a transit gateway, which acts as a central hub, to route traffic between your VPCs, VPN connections, and AWS Direct Connect connections.
VPC Flow Logs: A flow log captures information about the IP traffic going to and from network interfaces in your VPC.
VPN connections: Connect your VPCs to your on-premises networks using AWS Virtual Private Network (AWS VPN).
Hosting Web Applications.**
Hosting a Web or E-commerce site.**
Migrating workloads to the AWS cloud.**
Extending a Data Center to the cloud (Hybrid Cloud).**
Backup or Disaster Recovery.**
Security and Access Control.**
There's no additional charge for using a VPC.
But there are charges for some of the VPC components, such as
NAT gateways
IP Address Manager.
Traffic mirroring.
Reachability Analyzer.
Network Access Analyzer.
For creating functional VPC, we must create these components:
VPC
Internet Gateway
Subnets
Route table
Security Groups
NACL
VPC only: which will create only VPC.
VPC and more: which will create all the components required for the functional VPC at once.
inbound rules:
outbound rules:
Fully functional Amazon VPC had been created successfully:
For more information, see official
Or else you can use to calculator your estimates.