Connectivity and DNS
หลังสร้าง VPC แล้ว คุณต้องตัดสินใจว่า traffic จะเชื่อมกับ AWS services, VPC อื่น, on-premises และผู้ใช้ภายนอกอย่างไร รวมถึง DNS จะ resolve ชื่อไปที่ใด
VPC Endpoint และ AWS PrivateLink
VPC Endpoint ช่วยให้ resource ใน VPC เชื่อมต่อ AWS service หรือ endpoint service โดยไม่ต้องออก public internet Gateway Endpoint ใช้กับ Amazon S3 และ DynamoDB ส่วน Interface Endpoint ใช้ Elastic Network Interface พร้อม private IP ใน subnet และพึ่ง DNS
VPC Peering, Transit Gateway, VPN และ Direct Connect
| Connectivity | เหมาะกับ | ข้อควรระวัง |
|---|---|---|
| VPC Peering | เชื่อม VPC สองตัวโดยตรง | ไม่มี transitive routing และ CIDR ห้าม overlap |
| Transit Gateway | hub-and-spoke หลาย VPC / VPN / Direct Connect | ต้องวาง route table และ attachment design ให้ดี |
| Site-to-Site VPN | เชื่อม on-premises ผ่าน encrypted tunnel บน Internet | ขึ้นกับ Internet path และ bandwidth |
| Direct Connect | private dedicated connection ไป AWS | ต้องวาง physical/provider process และ redundancy |
Route 53
Amazon Route 53 เป็น highly available DNS service ใช้ได้ทั้ง domain registration, DNS routing และ health checking Hosted Zone เป็น container ของ DNS records แบ่งเป็น Public Hosted Zone สำหรับ Internet และ Private Hosted Zone สำหรับ VPC
- A / AAAA: ชี้ชื่อไป IPv4 / IPv6
- CNAME: ชี้ชื่อหนึ่งไปอีกชื่อหนึ่ง
- Alias: ชี้ไป AWS resource เช่น ALB หรือ CloudFront โดยไม่เสีย DNS query แบบเดียวกับ CNAME บางกรณี
- MX / TXT: ใช้กับ mail และ verification/security records
CloudFront และ ACM
CloudFront เป็น CDN สำหรับ cache content ใกล้ผู้ใช้ ลด latency และลด load ที่ origin เช่น ALB หรือ S3 AWS Certificate Manager หรือ ACM ใช้จัดการ TLS certificate สำหรับ HTTPS บน AWS services ที่รองรับ
Common mistakes
- ใช้ NAT Gateway สำหรับ traffic ไป S3/DynamoDB จำนวนมาก ทั้งที่ Gateway Endpoint อาจเหมาะกว่า
- ทำ VPC Peering หลายเส้นจน route ซับซ้อนและ CIDR overlap กลายเป็น blocker
- สร้าง Private Hosted Zone แต่ลืม associate กับ VPC ที่ต้อง resolve
- ใช้ DNS TTL สูงเกินไปในระบบที่ต้อง failover เร็ว
Review questions
- เลือก Gateway Endpoint หรือ Interface Endpoint ตาม service ได้
- รู้ข้อจำกัดของ VPC Peering และเหตุผลที่ใช้ Transit Gateway
- แยก Public Hosted Zone กับ Private Hosted Zone ได้
- Gateway Endpoint ต่างจาก Interface Endpoint อย่างไร?
- เมื่อใด Transit Gateway เหมาะกว่า VPC Peering?
- Public Hosted Zone ต่างจาก Private Hosted Zone อย่างไร?