IGW is the door that connects your VPC to the internet. Without it, nothing inside your VPC can talk to the outside world, and no one outside can reach your resources.
EC2 → IGW → Internet
EC2 ← IGW ← Internet
A VPC can only have one IGW attached, and one IGW can only be attached to one VPC.
VPC-A → IGW-1 (correct)
VPC-B → IGW-2 (correct)
VPC-A → IGW-1 + IGW-2 (not allowed)
VPC-A + VPC-B → IGW-1 (not allowed)
You create the VPC and IGW separately, then attach them together. They are not automatically linked.
After attaching an IGW, you still need to update the Route Table. The IGW is the door, but the Route Table is the sign that tells traffic how to find it.
AWS manages IGW automatically. It never goes down and scales with your traffic. You do not need to maintain it.
To give an EC2 instance internet access, follow these steps in order:
Step 1 - Create IGW Go to VPC console → Internet Gateways → Create
Step 2 - Attach IGW to your VPC Select the IGW → Actions → Attach to VPC
Step 3 - Update Route Table Add a route in the subnet's route table: