An Internet Gateway (IGW) in AWS is a horizontally scaled, redundant, and highly available VPC component that allows communication between instances in your VPC and the internet. It serves as the entry and exit point for traffic destined for or originating from the internet.
In simple terms, an Internet Gateway enables instances within your VPC to connect to the internet to access resources outside of the VPC, such as websites, APIs, or external services. Likewise, it allows external entities on the internet to initiate connections with instances inside your VPC.
When it comes to subnets in AWS, the relationship with Internet Gateways is crucial for enabling internet connectivity for instances within those subnets. To establish internet connectivity for instances in a subnet, the subnet must be associated with a route table that includes a route to the internet gateway. This route table is often referred to as a "public" route table because it contains a route for internet-bound traffic.
Typically, subnets that require internet connectivity for their instances are referred to as "public subnets." These public subnets have a route to the internet gateway in their associated route table, allowing instances within them to send and receive traffic to and from the internet.
Conversely, subnets that do not require direct internet connectivity for their instances are referred to as "private subnets." Instances within private subnets can still communicate with the internet through other means, such as using a NAT Gateway or NAT instance in a public subnet.
In summary, an Internet Gateway in AWS enables internet connectivity for instances within your VPC, and its association with the route tables of subnets determines which subnets have direct internet access.