AWS VPC allows creating a custom network environment with control over infrastructure. Communication in a VPC involves routing traffic between AWS resources, internet, and on-premises networks.
An Internet Gateway (IGW) allows communication between instances within the VPC and the internet. Traffic flow for public subnets and incoming traffic from external users to the web server via IGW is explianed.
NAT Gateway comes into play for private subnets that do not have direct access to the internet. The traffic flow via NAT Gateway explained with an example.
Route Tables control how traffic flows within the VPC and between subnets. Route table example explained with two instances in different subnets.
Security is crucial in a VPC setup. AWS provides Network Access Control Lists (NACLs) and Security Groups for controlling network traffic.
NACLs filter traffic at subnet level based on explicit inbound and outbound rules. Example of denial of all inbound traffic on port 22 using NACL.
Security Groups act as stateful firewalls for EC2 instances. Allow inbound traffic, and return traffic is automatically allowed. Examples of security group rules provided.
NACLs is better for broad filtering across multiple instances, while Security Groups are associated directly with specific instances.
Layered security approach combining NACLs and Security Groups is recommended. Examples of common security scenarios and common mistakes to avoid are also mentioned.
The article concludes with a mermaid diagram illustrating how the communication flow works, from internet to the VPC and across subnets.