AWS Certificate Manager (ACM)
AWS Certificate Manager, SSL/TLS Certificates, DNS/Email Validation, Auto Renewal
Tổng quan
AWS Certificate Manager (ACM) là dịch vụ quản lý SSL/TLS certificates, giúp bạn dễ dàng provision, quản lý và deploy certificates cho các AWS services và ứng dụng.
SSL/TLS là gì?
Tại sao cần ACM?
| Không có ACM | Có ACM |
|---|---|
| Tự mua certificate từ CA | AWS cấp miễn phí |
| Tự cài đặt lên server | Tự động deploy |
| Tự renew trước khi hết hạn | Tự động renew |
| Quản lý private key | AWS quản lý an toàn |
Các loại Certificate
1. Public Certificates (ACM-issued)
Certificates được cấp bởi Amazon Trust Services - một public Certificate Authority được browsers tin tưởng.
Đặc điểm:
- ✅ Miễn phí khi dùng với AWS services
- ✅ Tự động renew
- ✅ Được browsers tin tưởng globally
- ❌ Không export được private key (trước đây)
- ✅ Có thể export (từ 2025, có phí)
2. Imported Certificates
Certificates bạn mua từ CA khác (DigiCert, Let's Encrypt, etc.) và import vào ACM.
Đặc điểm:
- ✅ Import miễn phí
- ✅ Có thể dùng với AWS services
- ❌ Không tự động renew
- ⚠️ ACM sẽ cảnh báo trước khi hết hạn
3. Private Certificates (AWS Private CA)
Certificates cho internal applications, không cần public trust.
Tính năng chính
1. Centralized Management
2. Secure Key Storage
- Private keys được lưu trữ và mã hoá bởi AWS
- Keys không bao giờ rời khỏi ACM (trừ exportable certs)
- Được bảo vệ bởi AWS KMS
3. Automatic Renewal
Điều kiện để auto-renew:
- Certificate được cấp bởi ACM (không phải imported)
- Certificate đang được sử dụng với AWS service
- DNS validation record vẫn còn (nếu dùng DNS validation)
4. Wildcard Support
Tip: Request certificate với cả root và wildcard:
example.com*.example.com
Tích hợp với AWS Services
ACM tích hợp native với nhiều AWS services:
| Service | Use Case |
|---|---|
| Elastic Load Balancer (ALB/NLB) | HTTPS termination |
| CloudFront | HTTPS cho CDN distributions |
| API Gateway | Custom domain với HTTPS |
| Elastic Beanstalk | HTTPS cho web apps |
| AWS Amplify | HTTPS cho frontend hosting |
| AWS App Runner | HTTPS cho container apps |
Lưu ý quan trọng về Region:
Tại sao CloudFront yêu cầu Certificate ở US-EAST-1?
CloudFront là Global Service - không thuộc region nào cụ thể:
Quan trọng: Certificate ở us-east-1 chỉ là nơi lưu config, không ảnh hưởng latency!
AWS Global Services (Control Plane ở US-EAST-1)
Đây là các services cũng lưu configs ở us-east-1:
| Service | Config ở US-EAST-1 | Mô tả |
|---|---|---|
| CloudFront | ✅ | CDN toàn cầu |
| Route 53 | ✅ | DNS toàn cầu |
| IAM | ✅ | Users, Roles, Policies |
| WAF (cho CloudFront) | ✅ | Web ACLs cho CloudFront |
| AWS Organizations | ✅ | Multi-account management |
| AWS Global Accelerator | ✅ | Anycast routing |
| ACM (cho CloudFront) | ✅ | Certificates cho CloudFront |
Tạo Certificate ở nhiều Regions
Bạn có thể tạo cùng certificate ở nhiều regions (đều miễn phí!):
Cùng DNS validation record có thể validate cho cả 2 certificates!
Quy trình tạo Certificate
Step 1: Request Certificate
Step 2: Validate Domain Ownership
Bạn phải chứng minh mình sở hữu domain (xem phần Validation Methods)
Step 3: Certificate Issued
Sau khi validate thành công, certificate sẽ được cấp trong vài phút.
Validation Methods
1. DNS Validation (Khuyến nghị ✅)
Thêm một CNAME record vào DNS:
Ưu điểm:
- ✅ Chỉ cần setup 1 lần
- ✅ Tự động renew (nếu giữ CNAME record)
- ✅ Không cần email
Dùng Route 53? ACM có thể tự động tạo record cho bạn!
2. Email Validation
ACM gửi email đến domain owner addresses:
Ưu điểm:
- Không cần access DNS
Nhược điểm:
- ❌ Phải có email setup
- ❌ Phải manually approve cho mỗi lần renew
- ❌ Không khuyến nghị cho production
Certificate Renewal
ACM-issued Certificates
Imported Certificates
Import Certificate từ bên ngoài
Khi nào cần import?
- Đã có certificate từ CA khác
- Cần Extended Validation (EV) certificate (hiển thị tên công ty)
- Cần certificate cho non-AWS resources (nhưng muốn quản lý tập trung)
Cách import:
Requirements:
| Component | Format | Required |
|---|---|---|
| Certificate | PEM | ✅ |
| Private Key | PEM (unencrypted) | ✅ |
| Certificate Chain | PEM | ⚠️ Recommended |
Private Certificate Authority
AWS Private CA cho phép tạo private PKI infrastructure.
Use Cases:
Pricing (đắt!):
| Component | Cost |
|---|---|
| General-purpose CA | $400/month |
| Short-lived cert CA (≤7 days) | $50/month |
| Private certificates | Tiered pricing |
Giới hạn và Lưu ý
Regional Limits:
| Resource | Default Limit |
|---|---|
| ACM certificates per region | 2,500 |
| Domains per certificate | 10 (có thể tăng lên 100) |
| Private CAs per account | 200 |
Quan trọng:
Workaround cho EC2:
- Dùng ALB/NLB phía trước
- Import certificate từ bên ngoài (Let's Encrypt)
- Dùng exportable certificates ($15-149/year)
Pricing
Public Certificates (ACM-issued):
| Type | Cost |
|---|---|
| Non-exportable (dùng với AWS services) | FREE ✅ |
| Exportable - Standard domain | $15/year |
| Exportable - Wildcard | $149/year |
Imported Certificates:
| Action | Cost |
|---|---|
| Import | FREE |
| Use with AWS services | FREE |
Private CA:
| Component | Cost |
|---|---|
| General-purpose CA | $400/month |
| Short-lived CA | $50/month |
| Certificates (1-1000) | $0.75 each |
| Certificates (1001-10000) | $0.35 each |
Best Practices
1. Dùng DNS Validation
2. Request cả Root và Wildcard
3. Giữ DNS Validation Records
4. Monitor Certificate Expiry
5. Cho CloudFront - Luôn dùng us-east-1
So sánh với các giải pháp khác
| Feature | ACM | Let's Encrypt | Commercial CA |
|---|---|---|---|
| Cost | Free | Free | $10-1000+/year |
| Auto Renewal | ✅ | ✅ (với certbot) | ❌ |
| Validity | 13 months | 90 days | 1-2 years |
| Wildcard | ✅ | ✅ | ✅ |
| EV Certificate | ❌ | ❌ | ✅ |
| AWS Integration | ✅✅✅ | ⚠️ (import) | ⚠️ (import) |
| Use on EC2 | ❌ (trực tiếp) | ✅ | ✅ |
| Management | AWS Console | CLI/automation | Manual |
Exam Tips
💡 CloudFront certificates phải ở us-east-1 - Đây là câu hỏi phổ biến!
💡 ACM certificates miễn phí khi dùng với AWS services (ELB, CloudFront, API Gateway)
💡 Không thể export private key từ ACM standard certificates - nếu cần key, dùng exportable hoặc import từ bên ngoài
💡 DNS validation > Email validation cho production workloads
💡 Private CA đắt ($400/month) - chỉ dùng cho enterprise use cases
💡 ACM không hỗ trợ trực tiếp trên EC2 - phải dùng qua Load Balancer hoặc import certificate khác