AWS Systems Manager (SSM)
Run Command, Session Manager, Patch Manager, Parameter Store, Automation
Tổng quan
AWS Systems Manager (SSM) là dịch vụ giúp bạn quản lý tập trung nodes (EC2, on-premises, multicloud) ở quy mô lớn.
SSM Agent
SSM Agent là phần mềm cài trên nodes để cho phép Systems Manager quản lý.
| Aspect | Chi tiết |
|---|---|
| Cài đặt | Pre-installed trên nhiều AMIs (Amazon Linux, Windows Server) |
| Yêu cầu | Cần IAM role với permissions cho SSM |
| Hỗ trợ | EC2, on-premises, edge devices, multicloud VMs |
SSM Agent hoạt động như thế nào?
Agent có sẵn hay phải cài?
| AMI | SSM Agent |
|---|---|
| Amazon Linux 2/2023 | ✅ Có sẵn, đang chạy |
| Windows Server 2016+ | ✅ Có sẵn |
| Ubuntu 16.04+ (AWS AMIs) | ✅ Có sẵn |
| On-premises servers | ❌ Phải cài thủ công |
| Custom AMIs | ⚠️ Có thể chưa có |
[!NOTE] Agent có sẵn ≠ SSM hoạt động. Cần thêm IAM Role và network connectivity!
Network Connectivity cho SSM Agent
Agent cần ĐƯỜNG ĐI để gọi ra SSM Service. Có 2 options:
| Scenario | Dùng gì? |
|---|---|
| EC2 có public IP | Internet (không cần thêm gì) |
| Private subnet + NAT Gateway | Internet (qua NAT) |
| Private subnet + KHÔNG có NAT | VPC Endpoints (bắt buộc) |
| Yêu cầu security cao | VPC Endpoints (recommended) |
Tại sao SSM Agent an toàn hơn SSH?
| SSH (Port 22 INBOUND) | SSM Agent (OUTBOUND) | |
|---|---|---|
| Ai initiate connection? | Ai cũng có thể thử | Chỉ Agent initiate |
| Attack surface | Lớn (exposed) | 0 (không mở port) |
| Brute force? | ✅ Có thể | ❌ Không thể |
| Port scan? | ✅ Phát hiện được | ❌ Không scan được |
| Authentication | SSH keys (có thể bị leak) | IAM (integrated với AWS) |
| Logging | Phải setup riêng | ✅ Tích hợp CloudTrail/CloudWatch |
[!TIP] OUTBOUND đến AWS endpoints an toàn hơn nhiều so với INBOUND port mở! Giống như: Nhà đóng kín cửa, bạn chỉ gọi điện ra khi cần - không ai vào được.
Phân loại SSM Tools
Node Tools (Chi tiết)
1. Run Command 🚀
Mục đích: Chạy commands từ xa trên nhiều nodes cùng lúc mà không cần SSH.
| Feature | Mô tả |
|---|---|
| Không cần SSH | Không cần mở port 22, không cần SSH keys |
| Rate Control | Chạy theo batches (VD: 10 servers cùng lúc) |
| Error Threshold | Dừng nếu quá nhiều failures |
| Logging | Output lưu vào S3 hoặc CloudWatch Logs |
2. Session Manager 🔐
Mục đích: Truy cập shell/console vào nodes không cần SSH, không cần mở ports.
| Benefit | Mô tả |
|---|---|
| Không cần SSH keys | Authenticate bằng IAM |
| Không cần bastion hosts | Direct access qua SSM |
| Không cần mở ports | Không mở port 22 (SSH) hoặc 3389 (RDP) |
| Fully auditable | Mọi session được log, có thể stream to S3/CloudWatch |
| Cross-platform | Linux shell, Windows PowerShell |
[!TIP] Session Manager là cách recommended để access EC2 instances vì security tốt hơn SSH truyền thống.
3. Patch Manager 🔧
Mục đích: Tự động patch OS và applications trên managed nodes.
| Feature | Mô tả |
|---|---|
| Patch Baselines | Define rules cho việc approve patches |
| Patch Groups | Nhóm instances để apply baselines khác nhau |
| Scan vs Install | Có thể chỉ scan hoặc scan + install |
| Compliance Reports | Báo cáo patches nào missing |
4. State Manager 📋
Mục đích: Duy trì cấu hình mong muốn trên nodes (desired state).
5. Inventory 📦
Mục đích: Thu thập metadata về software, configurations trên managed nodes.
| Thu thập được | Ví dụ |
|---|---|
| Applications | Installed software |
| AWS Components | AWS CLI version, SSM Agent version |
| Files | Specific files/directories |
| Network Config | IP addresses, MAC addresses |
| Windows Updates | Installed updates |
| Instance Details | OS version, hostname |
Application Tools (Chi tiết)
Parameter Store 🔑 (Quan trọng!)
Mục đích: Lưu trữ configuration data và secrets một cách secure.
Parameter Store Tiers
| Feature | Standard (FREE) | Advanced (PAID) |
|---|---|---|
| Số parameters | 10,000 | 100,000 |
| Max size | 4 KB | 8 KB |
| Parameter policies | ❌ | ✅ (expiration, notification) |
| Higher throughput | ❌ | ✅ |
| Cost | FREE | $0.05/parameter/month |
So sánh Parameter Store vs Secrets Manager
| Aspect | Parameter Store | Secrets Manager |
|---|---|---|
| Cost | FREE (Standard tier) | $0.40/secret/month |
| Rotation | Không tự động | ✅ Automatic rotation |
| Cross-account | Có (với RAM) | Có |
| Use case | General configs, simple secrets | Database credentials, API keys cần rotation |
[!TIP]
- Dùng Parameter Store cho: configs, non-rotating secrets (FREE!)
- Dùng Secrets Manager cho: DB passwords cần auto-rotation
Change Management Tools
Automation 🤖
Mục đích: Tự động hóa các tasks phức tạp bằng Automation Runbooks.
Maintenance Windows ⏰
Mục đích: Lên lịch chạy tasks trong khung thời gian định sẵn.
SSM Documents
SSM Documents định nghĩa actions mà Systems Manager thực hiện.
| Document Type | Dùng bởi | Mục đích |
|---|---|---|
| Command | Run Command, State Manager | Chạy commands trên nodes |
| Automation | Automation | Runbooks cho automated tasks |
| Session | Session Manager | Configure session settings |
| Package | Distributor | Define software packages |
Ví dụ Document
Use Cases phổ biến
1. Secure Access to EC2 (thay thế SSH)
2. Centralized Patch Management
3. Configuration Management
4. Automation at Scale
Pricing
| Component | Pricing |
|---|---|
| Session Manager | FREE |
| Run Command | FREE |
| Patch Manager | FREE |
| State Manager | FREE |
| Parameter Store (Standard) | FREE (10,000 params) |
| Parameter Store (Advanced) | $0.05/parameter/month |
| Automation | FREE (first 100k steps/mo), then charges |
| OpsCenter | Charges per OpsItem |
[!NOTE] Hầu hết SSM tools là FREE! Đây là điểm mạnh lớn của SSM.
So sánh với các services khác
| Need | SSM Tool | Alternative |
|---|---|---|
| Store secrets | Parameter Store | Secrets Manager |
| SSH access | Session Manager | Bastion Host + SSH |
| Run commands | Run Command | SSH scripts |
| Patch OS | Patch Manager | Manual patching |
| Configuration | State Manager | Ansible, Puppet, Chef |
| Incident mgmt | Incident Manager | PagerDuty, OpsGenie |