Internet gateways, NAT and endpoints
Choose the destination first
A gateway connects a VPC to another network or supplies a path for traffic. An internet gateway (IGW) connects to the internet; a public NAT gateway lets private IPv4 clients initiate connections outward; a VPC endpoint provides access to a supported service without depending on an internet path. Start by asking whether the bookstore needs arbitrary internet access or just an AWS service. These are conceptual paths, not deployment commands.
Direct internet connectivity
For ordinary direct IPv4 internet connectivity, an attached IGW, an appropriate subnet route, a public IPv4 address or Elastic IP on the resource, and permitting network controls are required. The IGW maps the instance private IPv4 to its public address. A public IPv4 address alone is not enough. For publicly routable IPv6, the IGW forwards IPv6 without that IPv4 address mapping. Use an egress-only internet gateway for outbound-initiated IPv6 internet traffic with replies; it is not an IPv4 NAT gateway.
Trace a private IPv4 request
In this example, a private app subnet routes internet-bound IPv4 traffic to a zonal public NAT gateway in a public subnet in the same AZ. The NAT subnet routes to the IGW; the public NAT gateway has an Elastic IP. Responses use the established translation, but external hosts cannot initiate unsolicited connections through it. A private NAT gateway is different and does not provide direct internet access via an IGW. For multiple AZs, evaluate independent zonal gateways or the documented regional NAT gateway mode with automatic AZ expansion; check availability, configuration and billing before choosing.
app 10.42.11.20 -> nat-a -> IGW -> internetreply <- nat-a <- IGW <- internetPrivate service access and DNS
A gateway endpoint for S3 or DynamoDB adds service-prefix routes to selected route tables; it needs neither an IGW nor NAT for that traffic. An interface endpoint uses private IP addresses on endpoint ENIs for a supported service. Private DNS can map its usual service name to those addresses when configured correctly. DNS translates names to addresses, not permissions. VPC DNS attributes, endpoint policies where supported, IAM permissions and interface endpoint security groups still matter. Gateway endpoints have no additional endpoint charge; interface endpoints generally incur hourly and data-processing charges. Service charges remain.
Estimate cost before choosing
For a single zonal NAT gateway, use hypothetical rates of $0.06 per hour and $0.05 per GB processed. At 10 hours and 20 GB processed, the subtotal is $1.60. Add public IPv4, applicable transfer (including cross-AZ), logging and other charges separately; this is not a real AWS quote. Regional NAT pricing uses its own applicable dimensions; do not reuse this toy subtotal blindly. Consult the current VPC pricing page for the chosen Region before any deployment. If the only destination is supported in-Region S3, assess a gateway endpoint instead of paying NAT processing charges.
10 * 0.06 + 20 * 0.05 = 1.60 USD (hypothetical subtotal)Practice and cleanup planning
An app reads S3 objects and calls an external HTTPS API. Choose a gateway endpoint for S3 and a separately justified outbound path for the external API. If the external call is removed, reassess whether NAT is needed. A route to NAT can fail if its target or onward route is missing. In any optional authorized lab, remove dependent lab resources, routes, endpoints and NAT gateways in reviewed order, release unused lab-owned Elastic IPs, and check remaining billed resources. No account is needed here. Next: security groups and network ACLs.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Internet gateways, NAT and endpoints — knowledge check
Apply the lesson concepts to the fictional VPC.
A private IPv4 app must call an arbitrary public API. Which path matches the zonal example?
Which choice is appropriate for outbound-initiated internet access over publicly routable IPv6?
A private workload only reads S3 in its Region. Which option avoids NAT processing for this traffic?
With hypothetical rates $0.06/hour and $0.05/GB, what is the NAT subtotal for 10 hours and 20 GB?
What does private DNS on a suitably configured interface endpoint change?