0Pricing
Serverless AWS Lambda Development · Lektion

NAT-Gateways und Internetzugriff aus einer VPC

Lernen Sie, warum eine Lambda-Funktion in einem privaten VPC-Subnetz den Internetzugriff verliert und wie NAT-Gateways und VPC-Endpunkte die Verbindung sicher wiederherstellen.

NAT-Gateways und Internetzugriff aus einer VPC ist eine kostenlose Serverless AWS Lambda Development-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Serverless AWS Lambda Development-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Serverless AWS Lambda Development-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

The Surprise

A Lambda in a VPC can reach private resources, but it loses default internet access. Calls to public APIs suddenly time out.

Why It Happens

VPC Lambdas have no public IP. Without a route to the internet, outbound calls to external endpoints have nowhere to go.

Public vs Private Subnets

A public subnet routes to an Internet Gateway; a private subnet does not. Always place Lambdas in private subnets for security.

Enter the NAT Gateway

A NAT gateway lives in a public subnet and lets private subnets make outbound internet calls while staying unreachable from the internet.

The Route Table

The private subnet route table sends internet-bound traffic to the NAT gateway, which forwards it through the Internet Gateway.

Destination     Target
10.0.0.0/16     local
0.0.0.0/0       nat-0abc123

NAT Costs Money

NAT gateways charge per hour plus per GB processed. For heavy traffic this adds up, so consider whether you truly need public internet access.

VPC Endpoints Instead

To reach AWS services like S3 or DynamoDB, use a VPC endpoint. Traffic stays on the AWS network with no NAT needed and no per-GB internet cost.

Gateway vs Interface Endpoints

S3 and DynamoDB use free gateway endpoints; most other services use interface endpoints (powered by PrivateLink) which are billed hourly.

Calling S3 Through an Endpoint

No code change is needed. With a gateway endpoint and the right route, this S3 call never leaves the AWS backbone.

import boto3
s3 = boto3.client('s3')
s3.put_object(Bucket='my-bucket', Key='log.txt', Body=b'hi')

Choosing the Right Path

Need a public third-party API? Use a NAT gateway. Need only AWS services? Use VPC endpoints. Often you use endpoints to avoid NAT entirely.

Multi-AZ for Resilience

Deploy a NAT gateway per Availability Zone and put the Lambda in multiple subnets, so one AZ outage does not break connectivity.

Quick Check

Test your VPC networking knowledge.

Recap

You learned why VPC Lambdas lose internet access and how NAT gateways restore outbound access, while VPC endpoints reach AWS services privately and cheaply.

Häufig gestellte Fragen

Ist die Lektion „NAT-Gateways und Internetzugriff aus einer VPC“ kostenlos?

Ja — der vollständige Text von „NAT-Gateways und Internetzugriff aus einer VPC“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Serverless AWS Lambda Development-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Serverless AWS Lambda Development-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „NAT-Gateways und Internetzugriff aus einer VPC“?

Lernen Sie, warum eine Lambda-Funktion in einem privaten VPC-Subnetz den Internetzugriff verliert und wie NAT-Gateways und VPC-Endpunkte die Verbindung sicher wiederherstellen. Du übst Serverless AWS Lambda Development mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Serverless AWS Lambda Development zu starten?

Keine Vorkenntnisse erforderlich. Serverless AWS Lambda Development auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „NAT-Gateways und Internetzugriff aus einer VPC“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Serverless AWS Lambda Development-Lektion Code schreiben und ausführen?

Ja. Jede Serverless AWS Lambda Development-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Lambda in einer VPC für private Ressourcen
  2. Auf Datenbanken in einer VPC zugreifen
  3. Best Practices für Netzwerksicherheit
  4. NAT-Gateways und Internetzugriff aus einer VPC
← Zurück zu Serverless AWS Lambda Development