1.1.6 Create, Extend, and Maintain APIs
API Gateway
API Types
| Type | Use Case | Features |
|---|
| REST API | Full-featured APIs | WAF, request validation, caching, resource policies |
| HTTP API | Simple, low-latency | JWT authorizer, cheaper, faster |
| WebSocket API | Real-time two-way | Chat, gaming, streaming |
- Mapping templates (VTL — Velocity Template Language)
- Request validation (body, parameters, headers)
- Response status code overriding
Validation
- Request validators: body, query string parameters, headers
- Models (JSON Schema) cho request/response validation
Proxy vs Non-Proxy Integration
| Proxy Integration | Non-Proxy Integration |
|---|
| Request | Toàn bộ request → Lambda | Mapping template transform |
| Response | Lambda trả về format chuẩn | Mapping template transform |
| Flexibility | Ít | Nhiều |
| Complexity | Đơn giản | Phức tạp |
Exam Tip: Lambda Proxy Integration là phổ biến nhất. Response format bắt buộc: statusCode, headers, body.