Patch Manager for Linux and Windows
-
Phase 0: Before you start
-
Phase 1: The foundation
-
Phase 2: Operations and security
-
Phase 3: SQL Server on AWS
-
Phase 4: Troubleshooting step by step
-
Phase 5: Final project and career
Most breaches start with an unpatched server, and “we’ll patch next month” is how it stays unpatched. AWS Patch Manager is the part of Systems Manager that scans your Linux and Windows servers for missing patches, installs the ones your rules approve and reports on compliance, and you don’t have to log in to any server to do it.
You’ll launch a server from a six-month-old Amazon Linux image so it has plenty to patch, then write a patch baseline, scan, install, and set up a Sunday-night maintenance window. Last, you’ll fix the two problems that leave servers unpatched without anyone noticing.
| Time | You need | By the end you can |
|---|---|---|
| 60 minutes (one small instance and the Session Manager endpoints for under an hour) | saat-vpc, Start-SsmEndpoints.ps1 and Stop-SsmEndpoints.ps1, saat-ec2-ssm-profile, your laptop signed in as saat-admin. Cost: about USD 0.08. Patch Manager itself has no extra charge for EC2 instances. | Create a patch baseline and a patch group, run scans and installs with AWS-RunPatchBaseline, read patch compliance, schedule a maintenance window, and sort out patch group and instance state problems. |
What it is, in one line
AWS Patch Manager scans and patches EC2 and on-premises servers, using patch baselines to decide which patches are approved and maintenance windows to decide when they go in.
In Simple Words
The building maintenance checklist
A building manager doesn’t fix every dripping tap the moment it starts. They keep a checklist of what has to be fixed (fire alarms always, paint only if it’s peeling badly) and a time when work is allowed, which is Sunday night when the office is empty. The checklist is your patch baseline, the Sunday slot is the maintenance window, and the label on each floor saying which checklist applies is the patch group, so if someone writes a floor’s label wrong, that floor gets the default checklist, which might be very different from what you planned.
Engineer's View
How Patch Manager really works
Each operating system gets its own patch baseline, which holds the approval rules (a classification such as Security or Bugfix, a severity, and auto-approve after N days), lists of approved and rejected patches, and a compliance level. AWS gives you predefined baselines like AWS-AmazonLinux2023DefaultPatchBaseline, and AWS-DefaultPatchBaseline for Windows, which approves Critical and Security updates 7 days after release.
A patch group ties instances to a custom baseline through the PatchGroup (or Patch Group) tag, and any instance without a matching group falls back to the default baseline for its OS. The work itself is done by the AWS-RunPatchBaseline document: Operation=Scan only reports, while Operation=Install installs approved patches and, if you add RebootOption=RebootIfNeeded, reboots when it has to.
On Amazon Linux 2023, Patch Manager goes to the latest repository version even when the server is locked to an older release. Linux servers need to reach their package repositories (here that’s through the S3 gateway endpoint), and Windows servers need access to Windows Update or WSUS. Maintenance windows run tasks on a schedule with concurrency and error limits, and in newer accounts you can also use patch policies through Quick Setup across a whole organization.
How it works, step by step
This is how a server gets patched in the lab.
1The tag picks the baseline
patch01 is tagged PatchGroup=saat-web, and that group is registered to the saat-al2023 baseline, so the baseline’s approval rules apply to it.
2A scan reports the gap
Running AWS-RunPatchBaseline with Scan compares the installed packages against the approved updates and sends Installed, Missing and Failed counts back to Systems Manager.
3An install closes it
Run the same document with Install and it applies only the approved patches, reboots if a kernel or core library needs it, and reports again.
4A window makes it routine
Nobody should be running installs by hand every month. A normal routine looks like this:
Do the test groups first and production a few days later, so if a patch is bad you catch it before customers do.
✅ Checkpoint: You can explain baselines, patch groups and the default baseline, how Scan differs from Install, and what a maintenance window adds.
Hands-on lab: patch a real server with AWS Patch Manager
Before you run any command, double-check it
Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.
Start the usual way, and add a small helper that waits for a Run Command to finish:
cd C:\aws-lab
aws login --profile saat-admin
$env:AWS_PROFILE = 'saat-admin'
$v = Get-Content C:\aws-lab\saat-vpc.json | ConvertFrom-Json
.\Start-SsmEndpoints.ps1
function Wait-Command([string]$CommandId, [string]$InstanceId) {
do { Start-Sleep 15; $st = aws ssm get-command-invocation --command-id $CommandId --instance-id $InstanceId --query Status --output text 2>$null } until ($st -in 'Success', 'Failed', 'Cancelled', 'TimedOut')
$st
}1Launch a server that needs patches
Paste the whole block. It picks an Amazon Linux 2023 image that’s at least six months old:
$old = aws ec2 describe-images --owners amazon --include-deprecated --filters "Name=name,Values=al2023-ami-2023.*-kernel-6.1-x86_64" --query 'sort_by(Images,&CreationDate)[].[CreationDate,ImageId,Name]' --output text |
ForEach-Object { $d, $id, $n = $_ -split "`t"; [pscustomobject]@{ Date = [datetime]$d; Id = $id; Name = $n } } |
Where-Object { $_.Date -lt (Get-Date).AddMonths(-6) } | Select-Object -Last 1
$old.Name
$i = aws ec2 run-instances --image-id $old.Id --instance-type t3.micro --subnet-id $v.PrivateA --security-group-ids $v.AppSg --iam-instance-profile Name=saat-ec2-ssm-profile --metadata-options HttpTokens=required --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=patch01},{Key=PatchGroup,Value=saat-web},{Key=course,Value=saatvedha-aws},{Key=lesson,Value=27}]' --query "Instances[0].InstanceId" --output text
do { Start-Sleep 20; $p = aws ssm describe-instance-information --filters "Key=InstanceIds,Values=$i" --query "InstanceInformationList[0].PingStatus" --output text } until ($p -eq 'Online')
$pYou should see something like this:
al2023-ami-2023.7.20250414.0-kernel-6.1-x86_64
OnlineTeams don’t do this on purpose, but old images turn up all the time, like an Auto Scaling group with a launch template nobody updated, or a server built from a “golden” AMI two years ago.
2Create a baseline and a patch group
Paste this whole block:
@'
{
"PatchRules": [
{
"PatchFilterGroup": {
"PatchFilters": [
{ "Key": "CLASSIFICATION", "Values": [ "Security" ] },
{ "Key": "SEVERITY", "Values": [ "Critical", "Important" ] }
]
},
"ApproveAfterDays": 7,
"ComplianceLevel": "HIGH"
}
]
}
'@ | Set-Content patch-rules.json
$pb = aws ssm create-patch-baseline --name saat-al2023 --operating-system AMAZON_LINUX_2023 --description "Security, Critical and Important, after 7 days" --approval-rules file://patch-rules.json --tags Key=course,Value=saatvedha-aws --query BaselineId --output text
aws ssm register-patch-baseline-for-patch-group --baseline-id $pb --patch-group saat-web | Out-Null
aws ssm describe-patch-groups --query "Mappings[].[PatchGroup,BaselineIdentity.BaselineName]" --output textYou should see this:
saat-web saat-al2023Holding off seven days before auto-approving gives everyone else time to find a bad patch before it gets to you, and you can still add an emergency patch to the approved list by hand.
3Scan, then install
Paste the whole block. The install normally takes five to ten minutes, reboot included:
$scan = aws ssm send-command --document-name AWS-RunPatchBaseline --targets "Key=tag:PatchGroup,Values=saat-web" --parameters Operation=Scan --comment "lesson 27 scan" --query Command.CommandId --output text
Wait-Command $scan $i
aws ssm describe-instance-patch-states --instance-ids $i --query "InstancePatchStates[0].[Operation,InstalledCount,MissingCount,FailedCount]" --output text
aws ssm describe-instance-patches --instance-id $i --filters Key=State,Values=Missing --query "Patches[:3].[Title,Severity]" --output text
$inst = aws ssm send-command --document-name AWS-RunPatchBaseline --targets "Key=tag:PatchGroup,Values=saat-web" --parameters "Operation=Install,RebootOption=RebootIfNeeded" --comment "lesson 27 install" --query Command.CommandId --output text
Wait-Command $inst $i
aws ssm describe-instance-patch-states --instance-ids $i --query "InstancePatchStates[0].[Operation,InstalledCount,MissingCount,FailedCount]" --output textYou should see something like this, though your counts will be different:
Success
Scan 412 23 0
openssl-libs.x86_64:1:3.2.2-1.amzn2023.0.3 Important
kernel.x86_64:6.1.141-155.222.amzn2023 Important
glibc.x86_64:2.34-196.amzn2023.0.1 Important
Success
Install 435 0 0Twenty-three approved security patches were missing, the kernel among them, and now there are none. Because you targeted by tag, every server in the group would have been patched the same way. In the console you can get the same view under Systems Manager, then Patch Manager, then Compliance reporting.


4Schedule Sunday-night patching
Paste this whole block:
$mw = aws ssm create-maintenance-window --name saat-sunday-patching --schedule "cron(0 2 ? * SUN *)" --schedule-timezone Asia/Kolkata --duration 3 --cutoff 1 --no-allow-unassociated-targets --tags Key=course,Value=saatvedha-aws --query WindowId --output text
$wt = aws ssm register-target-with-maintenance-window --window-id $mw --resource-type INSTANCE --targets "Key=tag:PatchGroup,Values=saat-web" --query WindowTargetId --output text
'{ "RunCommand": { "Parameters": { "Operation": [ "Install" ], "RebootOption": [ "RebootIfNeeded" ] } } }' | Set-Content mw-task.json
aws ssm register-task-with-maintenance-window --window-id $mw --task-type RUN_COMMAND --task-arn AWS-RunPatchBaseline --targets "Key=WindowTargetIds,Values=$wt" --task-invocation-parameters file://mw-task.json --max-concurrency 50% --max-errors 10% --priority 1 | Out-Null
aws ssm get-maintenance-window --window-id $mw --query "[Name,Schedule,ScheduleTimezone,NextExecutionTime]" --output textYou should see something like this:
saat-sunday-patching cron(0 2 ? * SUN *) Asia/Kolkata 2026-10-25T02:00+05:30Every Sunday at 2 a.m. India time, saat-web gets patched half the servers at a time, and if more than 10 percent fail the run stops. The window stops starting new tasks one hour before its three-hour end, so nothing kicks off too late.
✅ Checkpoint: patch01 went from 23 missing patches to 0 on the saat-al2023 baseline, and saat-sunday-patching shows when it runs next. Keep it all for the break lab.
Break It, Then Fix It
Here are two ways servers stay unpatched while everyone thinks they’re covered.
1Break it: a typo in the patch group tag
Retag patch01 as saat-wbe and scan it by instance ID:
aws ec2 create-tags --resources $i --tags Key=PatchGroup,Value=saat-wbe
$scan = aws ssm send-command --document-name AWS-RunPatchBaseline --instance-ids $i --parameters Operation=Scan --query Command.CommandId --output text
Wait-Command $scan $i
aws ssm describe-instance-patch-states --instance-ids $i --query "InstancePatchStates[0].[PatchGroup,BaselineId]" --output textYou should see something like this:
Success
saat-wbe arn:aws:ssm:ap-south-1:111122223333:patchbaseline/pb-0f0e0d0c0b0a09080
The scan worked and nothing complained, but the baseline it used is AWS’s default for Amazon Linux 2023 and not saat-al2023. Its rules might be close to yours or nothing like them, and on top of that the server has dropped out of the maintenance window’s tag target. Fix: correct the tag, scan again and check the baseline name:
aws ec2 create-tags --resources $i --tags Key=PatchGroup,Value=saat-web
$scan = aws ssm send-command --document-name AWS-RunPatchBaseline --instance-ids $i --parameters Operation=Scan --query Command.CommandId --output text
Wait-Command $scan $i
aws ssm describe-instance-patch-states --instance-ids $i --query "InstancePatchStates[0].[PatchGroup,BaselineId]" --output text
$pbYou should see the same baseline ID twice, something like this:
Success
saat-web pb-0a9b8c7d6e5f43210
pb-0a9b8c7d6e5f432102Break it: patch a server that is stopped
Stop patch01 and then try to scan it:
aws ec2 stop-instances --instance-ids $i | Out-Null
aws ec2 wait instance-stopped --instance-ids $i
aws ssm send-command --document-name AWS-RunPatchBaseline --instance-ids $i --parameters Operation=ScanYou’ll get an error like this:
An error occurred (InvalidInstanceId) when calling the SendCommand operation: Instances [[i-0a1b2c3d4e5f60041]] not in a valid state for account 111122223333Run Command can only reach instances that are running and showing Online in Systems Manager, and you’ll get the same error for servers whose agent has lost its role or its route to the endpoints. Maintenance windows skip these servers without a word, so they slip further behind every month. Fix: start the server, wait for it to show Online and then patch it, and run a regular report on managed instances that aren’t Online:
aws ec2 start-instances --instance-ids $i | Out-Null
do { Start-Sleep 20; $p = aws ssm describe-instance-information --filters "Key=InstanceIds,Values=$i" --query "InstanceInformationList[0].PingStatus" --output text } until ($p -eq 'Online')
aws ssm describe-instance-information --query "InstanceInformationList[?PingStatus!='Online'].InstanceId" --output text
$pYou should see this. The middle command prints nothing when everything is Online:
OnlineNow clean up:
aws ssm delete-maintenance-window --window-id $mw | Out-Null
aws ssm deregister-patch-baseline-for-patch-group --baseline-id $pb --patch-group saat-web | Out-Null
aws ssm delete-patch-baseline --baseline-id $pb | Out-Null
aws ec2 terminate-instances --instance-ids $i | Out-Null
aws ec2 wait instance-terminated --instance-ids $i
.\Stop-SsmEndpoints.ps1
Remove-Item patch-rules.json, mw-task.json
.\Find-LabResources.ps1✅ Checkpoint: You found a server quietly using the default baseline because of a typo in its tag, and you saw InvalidInstanceId come back for a stopped server. The window, baseline, patch group and patch01 are all gone.
This happened at work
The servers that skipped a year of patches
A logistics company patched its whole fleet every month through a maintenance window targeting PatchGroup=prod, the compliance dashboard was green, and the security team trusted it. Then an outside auditor ran a vulnerability scan and found 31 servers missing critical patches that were more than a year old. When the team dug in, some of those servers had been launched by a team that tagged them Patch-Group=prod, and others had lost their instance role in a cleanup and weren’t managed at all. None of them showed up as non-compliant, because Patch Manager wasn’t looking at them in the first place. The fix wasn’t exciting but it worked: a Config rule that requires the PatchGroup tag with allowed values, a weekly report comparing all running instances with the Systems Manager managed instances, and Default Host Management Configuration so new instances are managed even when they have no instance profile.
Common mistakes and troubleshooting
| Mistake | What happens | What to do |
|---|---|---|
| Misspelled or missing PatchGroup tag | Default baseline, outside your maintenance window | Enforce allowed tag values with Config or tag policies |
| Only looking at compliance of managed instances | Unmanaged servers never appear | Compare EC2 inventory with Systems Manager managed instances |
| Install without RebootIfNeeded for kernel patches | Patches installed but not active | Reboot in the window, or track InstalledPendingReboot |
| Patching production first | A bad patch hits customers | Test patch group earlier in the week |
| Windows servers with no route to updates | Scan and install fail | Allow Windows Update through NAT or use WSUS |
| 100% concurrency in the window | Every server reboots at once | Use 25 to 50 percent and an error threshold |
Interview questions
Click a question to open it. Each one is phrased the way an interviewer would ask it, and under it you’ll find why they ask it and one way you could answer in your own words.
Fresher level
1. Can you explain in simple words what Patch Manager does in AWS?
Why they ask this: Patching is one of the most common jobs a cloud admin does, so they want to know you understand how servers are kept up to date in AWS.
How you might answer: Patch Manager is part of Systems Manager. It scans managed instances for missing operating system patches, installs them based on baselines and schedules, and reports which servers are compliant, so I can handle patching for Linux and Windows from one place without logging in to each server.
2. What is a patch baseline, and what would you normally put in one?
Why they ask this: They’re checking you understand how Patch Manager decides what to install, because without that you can’t explain why a server did or didn’t get a patch.
How you might answer: It’s a set of rules for one operating system that says which patches are approved. A typical rule would be Security updates with Critical or Important severity, approved 7 days after release, and when I need an exception I can add patches to an approved or rejected list.
3. What’s the difference between running Scan and running Install in Patch Manager?
Why they ask this: They want to see you know which action is safe to run any time and which one changes servers, since that decides when you run each.
How you might answer: Scan only tells you which patches are missing and doesn’t touch the server, while Install applies the approved patches and can reboot the server if needed. So I’m fine running Scan during the day, but Install goes into a maintenance window.
2–5 years experience
4. You built a custom baseline for your web servers, but they’re still using the default one. How do you fix that?
Why they ask this: It’s a test of whether you understand patch groups, which are one of the most common reasons a baseline seems to be ignored.
How you might answer: The only way an instance gets a custom baseline is through a patch group. I’d tag the web servers with PatchGroup (or Patch Group) and register that group to my custom baseline, because without a matching group Patch Manager uses the default baseline for that operating system, and that’s what was happening here.
5. Patching worked on most servers last night, but failed on a few Windows servers. Walk me through what you’d check.
Why they ask this: They want a logical troubleshooting order, starting with the basics before you dig into individual updates.
How you might answer: I’d start by checking SSM Agent is running, the instance shows as Online and the instance role is right. Then I’d look at network access to Windows Update or WSUS, free disk space, and whether a reboot was already pending, and after that I’d read the command output from the failed run to see which KBs failed and why.
6. Your team is worried that patching will reboot every server at the same time. How would you prevent that?
Why they ask this: They want to know you think about availability and not only about getting patches in, because taking a whole app down during patching is a classic mistake.
How you might answer: I’d run patching through maintenance windows with a max concurrency, say 25 percent, and an error threshold so it stops if too many fail, and I’d use separate windows for each patch group or AZ. For servers behind a load balancer, I’d make sure they’re drained before they reboot.
Senior level
7. Say you join a company with 2,000 servers across 20 AWS accounts and patching is done by hand. How would you design a better setup?
Why they ask this: They want to see you can design for scale and safety, thinking about coverage, staging and reporting and not only about installing patches.
How you might answer: I’d set up patch policies through Quick Setup across the organization, with baselines for each operating system and environment, and run patching in stages: dev first, then test, then production. I’d turn on Default Host Management Configuration so new servers are covered without anyone remembering to do it, send compliance to a central account and Security Hub, and keep track of any exceptions.
8. An auditor says some servers are missing patches, but Patch Manager shows them as compliant. How would you investigate?
Why they ask this: They want to see you don’t trust a green dashboard blindly, and that you go looking for gaps in coverage and in the rules.
How you might answer: I’d first check whether those servers are managed and Online at all, and when they last reported. Then I’d look at their patch group and baseline and at the baseline rules, for example a severity filter that skips Medium patches, or an approval delay. I’d fix coverage first so every server reports, and then fix the rules so compliant means patched.
Quick quiz
Q1. Which document runs patch scans and installs?
- AWS-RunShellScript
- AWS-RunPatchBaseline
- AWS-UpdateSSMAgent
- AWS-StartInteractiveCommand
Show answer
B — AWS-RunPatchBaseline with Operation Scan or Install.
Q2. What happens to an instance whose PatchGroup tag matches no group?
- It is skipped
- It uses the default baseline for its OS
- Patching fails
- It is rebooted
Show answer
B — The default baseline applies silently.
Q3. Why did send-command return InvalidInstanceId?
- Wrong document
- The instance was stopped
- The baseline was missing
- The tag was wrong
Show answer
B — Run Command needs a running, Online managed instance.
Q4. What does ApproveAfterDays 7 mean?
- Patches install 7 days after the scan
- Patches are approved 7 days after release
- Scans run every 7 days
- Reboots wait 7 days
Show answer
B — It gives time for bad patches to be found.
Q5. On Amazon Linux 2023, which repository version does Patch Manager use?
- The version locked on the server
- The latest repository version
- The AMI version only
- None
Show answer
B — Patch Manager uses the latest repository versions.
Quick recap
- Baselines decide which patches are approved, and patch groups attach them to servers through a tag.
- If the tag is missing or misspelled, the server quietly gets the default baseline.
- Scan reports, Install patches, and RebootIfNeeded is what makes kernel patches take effect.
- Maintenance windows run patching on a schedule with concurrency limits.
- Coverage matters, because stopped or unmanaged servers never get patched.
Next lesson
Lesson 28: Run Command, Automation and State Manager → Next you’ll run commands across many servers, automate fixes with Automation runbooks, and use State Manager to keep settings where you want them.
Further reading: AWS Patch Manager
Want to go deeper into AWS Patch Manager? Read AWS Systems Manager Patch Manager and How patch baseline rules work on Linux-based systems. You can also see the full plan for this course on the AWS Cloud Administration course page.
