A NAT gateway lets instances in a private subnet make outbound connections to the internet (updates, external APIs) while staying unreachable from inbound internet traffic. It’s a common pattern: private app servers + NAT for outbound, public load balancer for inbound.
Expanding on the short answer — what usually matters in practice:
A tiny example (an explanation template):
// Example: discuss trade-offs for "what-is-a-nat-gateway-and-when-do-you-need-it?"
function explain() {
// Start from the core idea:
// A NAT gateway lets instances in a private subnet make outbound connections to the internet
}