AWS Systems Manager · SSM
Operate a fleet of servers — EC2 and on-premises — without SSH, bastions or key pairs. One agent, one control plane, and a toolbox: shell into a box, run a script across a thousand boxes, patch them on a schedule, and store their config. Almost everything else on this page is a consequence of "the agent is installed and can reach the service".
Vận hành cả một đội server — EC2 và on-premises — không cần SSH, bastion hay key pair. Một agent, một control plane, và một hộp đồ nghề: mở shell vào máy, chạy script trên cả nghìn máy, vá theo lịch, và lưu cấu hình. Gần như mọi thứ còn lại trên trang này là hệ quả của "agent đã cài và kết nối được tới service".
Reach for it / not the right toolKhi nào dùng / khi nào không
Reach for Systems ManagerChọn Systems Manager
- Anything phrased as "without SSH", "without a bastion host", "without opening port 22", "without managing SSH keys".Bất cứ câu nào có "không SSH", "không bastion host", "không mở port 22", "không quản lý SSH key".
- Patching at scale on a schedule, with a compliance report at the end.Vá hàng loạt theo lịch, kèm báo cáo tuân thủ cuối cùng.
- One control plane for EC2 and on-premises / other clouds — the same commands work on both.Một control plane cho EC2 và on-prem / cloud khác — cùng bộ lệnh chạy cho cả hai.
- Storing config values and secrets that instances and Lambdas read at runtime.Lưu giá trị cấu hình và secret để instance và Lambda đọc lúc chạy.
Not the right toolKhông phải chỗ dùng
- Creating the infrastructure in the first place → CloudFormation / CDK. SSM manages what already exists.Tạo hạ tầng ngay từ đầu → CloudFormation / CDK. SSM quản cái đã tồn tại.
- Releasing application versions with rollback → CodeDeploy.Phát hành version ứng dụng có rollback → CodeDeploy.
- Secrets that must rotate automatically with a database → Secrets Manager, not Parameter Store.Secret phải tự rotate cùng database → Secrets Manager, không phải Parameter Store.
- Containers and serverless — no OS to manage. SSM's fleet tools are about instances.Container và serverless — không có OS để quản. Bộ công cụ fleet của SSM là cho instance.
How it works — the agent is the whole storyCách hoạt động — tất cả nằm ở agent
SSM never connects to your instance. The agent polls outbound to the SSM service and pulls work down. That single fact explains why there's no inbound port, why a private subnet works fine, and why a broken NAT route silently removes an instance from the console. SSM không bao giờ kết nối vào instance của bạn. Agent poll ra ngoài tới service SSM và kéo việc về. Chỉ một điều đó giải thích vì sao không cần port vào, vì sao private subnet vẫn chạy tốt, và vì sao route NAT hỏng là instance âm thầm biến mất khỏi console.
The agent ships preinstalled on Amazon Linux, recent Ubuntu, Windows Server and macOS AMIs. Everything below — sessions, commands, patching, inventory — is the same agent doing different work.
Agent cài sẵn trên AMI Amazon Linux, Ubuntu gần đây, Windows Server và macOS. Mọi thứ bên dưới — session, command, patching, inventory — vẫn là agent đó làm những việc khác nhau.
AmazonSSMManagedInstanceCore ·
3) no route out — a private subnet with no NAT and no VPC endpoints ·
4) the endpoints exist but the wrong ones: you need ssm and ssmmessages for Session Manager, plus ec2messages for Run Command, and their security group must allow 443 inbound from the instances.
Rà theo thứ tự này — gần như luôn là một trong số đó:
1) agent chưa cài hoặc không chạy ·
2) không có IAM instance profile, hoặc thiếu AmazonSSMManagedInstanceCore ·
3) không có đường ra — private subnet không NAT, không VPC endpoint ·
4) có endpoint nhưng sai loại: cần ssm và ssmmessages cho Session Manager, thêm ec2messages cho Run Command, và security group của chúng phải mở 443 vào từ các instance.
Session Manager — the answer to "no SSH"Session Manager — đáp án cho "không SSH"
A browser or CLI shell onto the instance, authorised by IAM rather than a key pair. The security group can have zero inbound rules and it still works. Một shell qua trình duyệt hoặc CLI vào instance, cấp quyền bằng IAM thay vì key pair. Security group có thể không có rule inbound nào mà vẫn dùng được.
Three audit surfaces, worth separating: IAM decides who may connect and to which instances (tag conditions work here), CloudTrail records that a session started, and session logs capture what was actually typed.
Ba mặt phẳng audit, nên tách rõ: IAM quyết ai được kết nối và vào instance nào (dùng được điều kiện theo tag), CloudTrail ghi lại việc session bắt đầu, và session log lưu những gì thực sự được gõ.
-
Supports Linux, macOS and Windows. Access via the Console,
aws ssm start-session, or the Session Manager plugin. Hỗ trợ Linux, macOS và Windows. Truy cập qua Console,aws ssm start-session, hoặc plugin Session Manager. - Port forwarding and SSH over SSM are both supported — so "reach an RDS instance in a private subnet from my laptop, without a bastion" is a Session Manager answer, not a bastion answer. Hỗ trợ cả port forwarding và SSH qua SSM — nên "kết nối tới RDS trong private subnet từ laptop, không cần bastion" là đáp án Session Manager, không phải bastion.
- Session preferences can force KMS encryption of session data, set an idle timeout, restrict the shell profile, and require logging before a session may start. Session preference có thể bắt buộc mã hoá KMS cho dữ liệu session, đặt idle timeout, giới hạn shell profile, và yêu cầu bật logging mới cho mở session.
- You can deny specific commands at the IAM level and remove the SSH key pairs entirely — the classic "developers must reach production without keys, and every command must be auditable" answer. Có thể chặn lệnh cụ thể ở mức IAM và bỏ hẳn SSH key pair — đáp án kinh điển cho "dev phải vào được production mà không có key, và mọi lệnh phải audit được".
Documents, Run Command & AutomationDocument, Run Command & Automation
A document is SSM's unit of work — JSON or YAML describing steps. Which type of document you write decides which engine runs it. Một document là đơn vị công việc của SSM — JSON hoặc YAML mô tả các bước. Loại document bạn viết quyết định engine nào chạy nó.
| Document typeLoại document | Runs where / what it's forChạy ở đâu / để làm gì |
|---|---|
| Command | On the instance, by the agent — Run Command. e.g. AWS-RunShellScript, AWS-RunPatchBaseline.Trên instance, do agent chạy — Run Command. vd AWS-RunShellScript, AWS-RunPatchBaseline. |
| Automation (runbook) | In the SSM service, calling AWS APIs — restart an instance, create an AMI, patch and then re-image. Can call Lambda, approvals, other runbooks.Trong service SSM, gọi API AWS — restart instance, tạo AMI, vá rồi tạo lại image. Gọi được Lambda, bước duyệt, runbook khác. |
| Session | Shapes what a Session Manager session may do (e.g. AWS-StartPortForwardingSession).Quy định session Session Manager được làm gì (vd AWS-StartPortForwardingSession). |
| Policy | Tells the agent to keep collecting something — this is how Inventory is gathered.Bảo agent thu thập liên tục thứ gì đó — đây là cách Inventory được thu. |
Worked example — act before an ASG kills an instanceVí dụ — hành động trước khi ASG giết instance
The canonical Automation pattern. A scale-in is about to destroy a machine that still holds logs, or a live user session, or an unfinished job. A lifecycle hook freezes it long enough to do something about that. Pattern Automation kinh điển. Một lần scale-in sắp huỷ máy vẫn còn giữ log, hoặc session người dùng, hoặc job chưa xong. Một lifecycle hook đóng băng nó đủ lâu để xử lý.
Same shape works for launch: Pending:Wait lets you install software or warm a cache before the instance is put behind the load balancer.
Cùng khuôn cho lúc launch: Pending:Wait cho phép cài phần mềm hoặc làm nóng cache trước khi instance được đưa vào sau load balancer.
Terminating:Wait until something calls CompleteLifecycleAction — or until the heartbeat timeout expires (default 1 hour, max 100 hours) and the default action takes over. Forget it and every scale-in stalls for an hour while you keep paying for the instance.
Bước 4 không phải tuỳ chọn. Lifecycle hook giữ instance ở Terminating:Wait cho tới khi có ai gọi CompleteLifecycleAction — hoặc tới khi hết heartbeat timeout (mặc định 1 giờ, tối đa 100 giờ) và hành động mặc định được áp dụng. Quên là mỗi lần scale-in treo cả tiếng trong khi vẫn trả tiền cho instance.
Parameter StoreParameter Store
Hierarchical storage for configuration and secrets, with IAM on every path. Values are versioned, and applications fetch them at runtime instead of baking them into an AMI or a container image. Kho lưu cấu hình và secret theo cây phân cấp, IAM áp lên từng đường dẫn. Giá trị có version, và ứng dụng lấy lúc chạy thay vì nhét vào AMI hay container image.
# hierarchy — IAM policies grant on path prefixes
/my-app/dev/db-url
/my-app/dev/db-password ← SecureString, encrypted with a KMS key
/my-app/prod/db-url
/my-app/prod/db-password
aws ssm get-parameters-by-path --path /my-app/prod --with-decryption
# AWS publishes public parameters too — no more hardcoded AMI ids
/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64
ssm:GetParameter and kms:Decryptmã hoá bằng KMS; người đọc cần cả ssm:GetParameter lẫn kms:Decrypt
| Parameter Store | Secrets Manager | |
|---|---|---|
| Automatic rotationTự động rotation | no — you'd write it yourselfkhông — phải tự viết | built in, with Lambda; native for RDS/Redshift/DocumentDBcó sẵn, dùng Lambda; hỗ trợ thẳng RDS/Redshift/DocumentDB |
| CostChi phí | free at standard tiermiễn phí ở tier standard | per secret, per monththeo secret, theo tháng |
| Cross-account accessTruy cập cross-account | via a shared KMS key / assumed rolequa KMS key dùng chung / assume role | resource policy on the secretresource policy trên secret |
| Also stores plain configLưu cả config thường | yes — that's its main jobcó — đó là việc chính của nó | possible but wastefulđược nhưng lãng phí |
{{resolve:ssm:/my-app/prod/db-url}} and {{resolve:secretsmanager:…}}. Parameter Store can also proxy a Secrets Manager secret via the /aws/reference/secretsmanager/ prefix — one API for code that only knows how to read parameters.
CloudFormation giải cả hai lúc deploy: {{resolve:ssm:/my-app/prod/db-url}} và {{resolve:secretsmanager:…}}. Parameter Store cũng có thể proxy một secret của Secrets Manager qua tiền tố /aws/reference/secretsmanager/ — một API duy nhất cho code chỉ biết đọc parameter.
The rest of the toolboxPhần còn lại của hộp đồ nghề
mi- ids and behave like EC2.đăng ký máy on-prem / cloud khác; nhận id mi- và hành xử như EC2.
Patch ManagerPatch Manager
At three servers you SSH in and run yum update. At three hundred that falls apart in four specific ways — and Patch Manager is the answer to all four. It is free.
Ba server thì SSH vào chạy yum update. Ba trăm server thì cách đó vỡ theo bốn kiểu rất cụ thể — và Patch Manager trả lời cả bốn. Nó miễn phí.
yum update takes everything — including the package upgrade that breaks your appyum update lấy tất cả — kể cả bản nâng cấp làm hỏng app của bạn
The four words, in plain termsBốn từ khoá, nói cho dễ hiểu
| TermThuật ngữ | What it actually isThực chất là gì |
|---|---|
| PatchPatch | one vendor update — a yum / apt package version, or a Windows KB… updatemột bản cập nhật của nhà cung cấp — một version package yum / apt, hoặc một bản KB… của Windows |
| Patch baselinePatch baseline | your policy: which patches count as approved — and which are banned outrightchính sách của bạn: bản vá nào được duyệt — và bản nào bị cấm hẳn |
| Patch groupPatch group | a label on machines (the tag Patch Group) so different fleets get different policiesmột nhãn trên máy (tag Patch Group) để các fleet khác nhau nhận chính sách khác nhau |
| Maintenance WindowMaintenance Window | the recurring time slot when disruption is allowedkhung giờ lặp lại mà việc gây gián đoạn được cho phép |
| ComplianceCompliance | the report: per instance — installed, missing, failedbáo cáo: theo từng instance — đã cài, còn thiếu, lỗi |
The baseline is the interesting one. It is not "install everything". You say: approve patches classified Security with severity Critical or Important, but only once they have been public for 7 days — and keep a rejected list for the package that breaks your app. Baseline mới là phần thú vị. Nó không phải "cài tất". Bạn nói: duyệt bản vá loại Security mức Critical hoặc Important, nhưng chỉ khi đã công bố được 7 ngày — và giữ một danh sách chặn cho package làm hỏng app của bạn.
The tag key is literally Patch Group, with a space, and an instance may belong to only one patch group. That's the detail exam questions hinge on.
Tag key đúng là Patch Group, có dấu cách, và một instance chỉ thuộc một patch group. Đó là chi tiết mà câu hỏi thi hay xoáy vào.
Worked example — staged rollout across environmentsVí dụ — triển khai theo tầng qua các môi trường
Three baselines, three patch groups, three different auto-approval delays. Same patch, reaching each environment at a different time. Ba baseline, ba patch group, ba mức trễ auto-approve khác nhau. Cùng một bản vá, tới mỗi môi trường vào thời điểm khác nhau.
Patch Group = dev
auto-approval delay 0 days — patched the moment a patch shipsđộ trễ auto-approve 0 ngày — vá ngay khi bản vá ra
Patch Group = staging
auto-approval delay 3 daysđộ trễ auto-approve 3 ngày
Patch Group = prod
auto-approval delay 7 daysđộ trễ auto-approve 7 ngày
The two ways you'll actually run itHai cách bạn thực sự sẽ chạy nó
Scan — the fire drilllúc khẩn cấp
- A critical vulnerability lands. Someone asks "are we exposed?"Một lỗ hổng nghiêm trọng xuất hiện. Có người hỏi "mình có dính không?"
- Run
AWS-RunPatchBaselinewithOperation: Scanfleet-wide. It changes nothing — it only reports.ChạyAWS-RunPatchBaselinevớiOperation: Scantrên cả fleet. Nó không thay đổi gì — chỉ báo cáo. - Minutes later: 340 instances fine, 60 missing it. Then
Installagainst just those 60.Vài phút sau: 340 instance ổn, 60 cái còn thiếu. RồiInstallchỉ cho 60 cái đó.
Install — the routinechạy định kỳ
- Configure once: window every third Saturday 02:00–06:00, targets
Patch Group = prod-windows.Cấu hình một lần: window vào thứ Bảy tuần thứ ba, 02:00–06:00, targetPatch Group = prod-windows. - Rate control 25% at a time, error threshold stop after 5 failures.Rate control 25% mỗi lượt, ngưỡng lỗi dừng sau 5 lỗi.
- Then you never think about it again — it runs monthly and produces a compliance report each time.Rồi bạn không phải nghĩ tới nữa — nó chạy hàng tháng và mỗi lần cho ra một báo cáo compliance.
- AWS ships a default baseline per OS that approves security patches after a delay. Build your own when you need to control classification, severity, an auto-approval delay, or an explicit reject list. AWS có sẵn baseline mặc định cho mỗi OS, duyệt bản vá bảo mật sau một khoảng trễ. Tự tạo baseline khi cần kiểm soát classification, severity, độ trễ auto-approve, hoặc danh sách chặn.
-
AWS-RunPatchBaselinetakes an Operation:Scanreports what's missing without changing anything;Installpatches and may reboot. Scan first is the safe rollout.AWS-RunPatchBaselinenhận tham số Operation:Scanchỉ báo cáo thiếu gì mà không đổi gì;Installvá và có thể reboot. Scan trước là cách triển khai an toàn. - A Maintenance Window can run any registered task, not just patching — Run Command, Automation, Lambda, Step Functions. It's the generic "do this in the approved window" scheduler. Maintenance Window chạy được bất kỳ task đăng ký nào, không chỉ patching — Run Command, Automation, Lambda, Step Functions. Nó là bộ lịch chung "làm việc này trong khung giờ được duyệt".
- Golden-AMI alternative: instead of patching live fleets, use an Automation runbook to launch, patch, snapshot and register a new AMI, then roll it out through the ASG. Trade downtime for immutability. Hướng golden-AMI: thay vì vá fleet đang chạy, dùng Automation runbook để launch, vá, snapshot rồi đăng ký AMI mới, sau đó roll qua ASG. Đánh đổi downtime lấy tính bất biến.
Exam reflexesPhản xạ khi thi
| The question says…Đề nói… | AnswerTrả lời |
|---|---|
| "Shell access to private instances without a bastion or SSH keys, fully audited""Truy cập shell vào instance private không bastion, không SSH key, có audit đầy đủ" | Session Manager + session logs to S3/CloudWatchSession Manager + session log ra S3/CloudWatch |
| "Run the same script on 500 instances, a few at a time, stop if too many fail""Chạy cùng script trên 500 instance, vài cái một lần, dừng nếu lỗi quá nhiều" | Run Command with rate control + error thresholdRun Command có rate control + ngưỡng lỗi |
| "Patch monthly during a window and prove compliance to an auditor""Vá hàng tháng trong khung giờ và chứng minh tuân thủ với auditor" | Patch Manager: baseline + Patch Group tag + Maintenance Window + patch compliancePatch Manager: baseline + tag Patch Group + Maintenance Window + patch compliance |
| "Instances in a private subnet with no NAT must still be managed""Instance ở private subnet không NAT vẫn phải quản được" | VPC interface endpoints for ssm, ssmmessages, ec2messagesVPC interface endpoint cho ssm, ssmmessages, ec2messages |
| "Upload logs before Auto Scaling terminates the instance""Đẩy log lên trước khi Auto Scaling huỷ instance" | Lifecycle hook → Terminating:Wait → EventBridge → SSM Automation → CompleteLifecycleActionLifecycle hook → Terminating:Wait → EventBridge → SSM Automation → CompleteLifecycleAction |
| "Store a DB password cheaply; rotation is not required""Lưu password DB rẻ; không cần rotation" | Parameter Store SecureString (if it must rotate → Secrets Manager)Parameter Store SecureString (nếu phải rotate → Secrets Manager) |
| "Which instances are missing a required agent / are on an old OS?""Instance nào thiếu agent bắt buộc / đang chạy OS cũ?" | Inventory (+ State Manager to keep it installed)Inventory (+ State Manager để giữ nó được cài) |
| "Same tooling for EC2 and our datacentre servers""Cùng bộ công cụ cho EC2 và server trong datacenter" | Hybrid activations — install the agent, register, get mi- nodesHybrid activation — cài agent, đăng ký, có node mi- |