Tuần 4 - Ngày 1: VPC Advanced Concepts
Mục tiêu học tập
- Hiểu sâu về VPC Endpoints
- Nắm vững VPC Peering và limitations
- Biết cách thiết kế multi-VPC architectures
1. VPC Endpoints
Types of VPC Endpoints
Gateway Endpoint Architecture
Interface Endpoint Architecture
Endpoint Policies
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowSpecificBucket",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::my-secure-bucket",
"arn:aws:s3:::my-secure-bucket/*"
]
}
]
}
DynamoDB: Gateway vs Interface Endpoint
DynamoDB hỗ trợ cả hai loại endpoint — biết lựa chọn nào cho SAP-C02 scenario là quan trọng.
| Tiêu chí | DynamoDB Gateway Endpoint | DynamoDB Interface Endpoint (PrivateLink) |
|---|---|---|
| Pricing | Miễn phí | $0.01/giờ/AZ + data processing |
| Access từ trong VPC | ✓ | ✓ |
| Access từ on-premises (DX/VPN) | ✗ Không hỗ trợ | ✓ Có |
| Cross-region access | ✗ | ✓ (qua VPC peering / TGW) |
| Setup | Add route vào route table | Tạo ENI trong subnet |
| DNS resolution | Public DNS → private route | Private DNS name |
| Use case mặc định | Mọi traffic trong VPC | Hybrid: on-prem cần truy cập DynamoDB |
Exam keyword:
- "Most cost-effective access to DynamoDB from VPC" → Gateway Endpoint (free)
- "Access DynamoDB from on-premises through Direct Connect/VPN" → Interface Endpoint (PrivateLink)
- "Hybrid architecture, on-prem app calls DynamoDB privately" → Interface Endpoint
Lưu ý: S3 cũng có cả hai loại endpoint với pattern tương tự (S3 Interface Endpoint GA 2021 cho hybrid use case).
2. VPC Peering
How it works
Key Characteristics
- Non-transitive: Traffic cannot transit through peered VPC
- Cross-region: Supported with inter-region peering
- Cross-account: Supported with accepter approval
- No overlapping CIDR: VPCs cannot have overlapping IP ranges
Transitive Peering Problem
VPC Peering Limitations
| Limitation | Detail |
|---|---|
| Max peers per VPC | 125 |
| Bandwidth | No aggregate limit |
| Transitive routing | Not supported |
| Overlapping CIDR | Not supported |
| DNS resolution | Needs enablement |
3. Multi-VPC Architectures
Pattern 1: Hub-and-Spoke (Full Mesh Peering)
Pattern 2: Transit Gateway (Recommended)
4. Private DNS with VPC
Route 53 Private Hosted Zone
Route 53 Resolver
5. VPC Design Best Practices
CIDR Planning
Subnet Design
6. Câu hỏi ôn tập
-
Gateway Endpoint và Interface Endpoint khác nhau như thế nào?
Xem đáp án
Gateway Endpoint: chỉ S3 và DynamoDB, miễn phí, được add vào route table, không tạo ENI. Interface Endpoint: hầu hết AWS services, có phí (~$0.01/giờ/AZ + $0.01/GB), tạo ENI với Private IP trong subnet, hỗ trợ Private DNS. Interface Endpoint dùng PrivateLink — có thể dùng cho custom services (qua NLB). Gateway Endpoint đơn giản và miễn phí cho S3/DynamoDB; Interface Endpoint cho other services cần private access.
-
VPC Peering có hỗ trợ transitive routing không?
Xem đáp án
Không — VPC Peering không có transitive routing. Nếu A-B peer và B-C peer: A không thể reach C qua B. Phải tạo direct A-C peering. Với nhiều VPCs (N VPCs), cần N×(N-1)/2 peering connections — không scalable. Transit Gateway giải quyết: hub-and-spoke, transitive routing, N connections thay vì N² connections.
-
Khi nào nên dùng VPC Peering vs Transit Gateway?
Xem đáp án
VPC Peering khi: 2-4 VPCs cần kết nối, không cần transitive routing, muốn giảm cost (peering miễn phí, TGW có phí attachment + processing), không cần centralized routing control. Transit Gateway khi: nhiều hơn 5 VPCs, cần transitive routing, cần centralized network hub (VPN + DX + VPCs từ 1 điểm), cần cross-region (TGW peering), cần network segmentation với route tables riêng.
-
Route 53 Resolver Inbound endpoint dùng để làm gì?
Xem đáp án
Inbound Endpoint cho phép on-premises DNS servers forward queries đến Route 53 Resolver để resolve AWS private hosted zones và VPC internal hostnames. On-premises DNS forward requests đến Inbound Endpoint IPs (trong VPC) qua Direct Connect hoặc VPN. Ngược lại, Outbound Endpoint cho phép VPC EC2 instances forward DNS queries ra on-premises DNS servers.
-
Tại sao cần plan CIDR ranges carefully?
Xem đáp án
Overlapping CIDRs gây không thể peering VPCs (VPC Peering không hoạt động với overlapping CIDRs). Với Transit Gateway, overlapping CIDRs gây routing ambiguity. Multi-account environments cần non-overlapping CIDRs across tất cả VPCs/accounts. AWS IPAM giúp centralize CIDR management. Planning từ đầu: assign CIDR ranges per account/Region (ví dụ: 10.0.0.0/8 cho toàn org, chia /12 per region, /16 per account).
7. Bài tập thực hành
- Create S3 Gateway Endpoint
- Create Interface Endpoint for Secrets Manager
- Setup VPC Peering between 2 VPCs
- Configure Route 53 Private Hosted Zone
Tài liệu tham khảo chính thức
Ngày tiếp theo: Transit Gateway Deep Dive