0Pricing
Serverless AWS Lambda Development · บทเรียน

เกตเวย์ NAT และการเข้าถึงอินเทอร์เน็ตจาก VPC

เรียนรู้ว่าเหตุใด Lambda ภายในซับเน็ตส่วนตัวของ VPC จึงสูญเสียการเข้าถึงอินเทอร์เน็ต และเกตเวย์ NAT กับปลายทาง VPC ช่วยคืนการเชื่อมต่ออย่างปลอดภัยได้อย่างไร

เกตเวย์ NAT และการเข้าถึงอินเทอร์เน็ตจาก VPC เป็นบทเรียน Serverless AWS Lambda Development ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Serverless AWS Lambda Development และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Serverless AWS Lambda Development มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

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.

คำถามที่พบบ่อย

บทเรียน “เกตเวย์ NAT และการเข้าถึงอินเทอร์เน็ตจาก VPC” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “เกตเวย์ NAT และการเข้าถึงอินเทอร์เน็ตจาก VPC” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Serverless AWS Lambda Development ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Serverless AWS Lambda Development มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “เกตเวย์ NAT และการเข้าถึงอินเทอร์เน็ตจาก VPC”

เรียนรู้ว่าเหตุใด Lambda ภายในซับเน็ตส่วนตัวของ VPC จึงสูญเสียการเข้าถึงอินเทอร์เน็ต และเกตเวย์ NAT กับปลายทาง VPC ช่วยคืนการเชื่อมต่ออย่างปลอดภัยได้อย่างไร คุณปฏิบัติ Serverless AWS Lambda Development ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Serverless AWS Lambda Development หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Serverless AWS Lambda Development บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “เกตเวย์ NAT และการเข้าถึงอินเทอร์เน็ตจาก VPC” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Serverless AWS Lambda Development นี้ได้ไหม

ได้ บทเรียน Serverless AWS Lambda Development ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. Lambda ใน VPC สำหรับทรัพยากรส่วนตัว
  2. การเข้าถึงฐานข้อมูลใน VPC
  3. แนวทางปฏิบัติที่ดีด้านความปลอดภัยเครือข่าย
  4. เกตเวย์ NAT และการเข้าถึงอินเทอร์เน็ตจาก VPC
← กลับไปที่ Serverless AWS Lambda Development