Build walkthrough · Security & Patching
Patch Management on AWS: Systems Manager, AMIs, Containers and Lambda
A practical walkthrough of patching EC2 with Systems Manager Patch Manager, rebuilding AMIs, and keeping ECS/EKS images and Lambda runtimes current.
In short
AWS patch management means running Systems Manager Patch Manager against EC2 for OS-level fixes, rebuilding AMIs and container images for anything that should be immutable, and tracking ECS/EKS base images and Lambda runtimes as separate patch surfaces with their own deprecation clocks. None of these four streams covers the others, and most incidents happen in the gap between them.
This walkthrough covers Patch Manager's actual building blocks, when to patch in place versus rebuild the image, and how to keep container and Lambda currency from falling off a maintenance window's radar.
What Patch Manager actually automates
AWS Systems Manager Patch Manager automates OS patching (and some application patching) for managed EC2 instances and on-premises nodes registered with the agent. The mechanics, per the AWS documentation, break into four pieces:
- Patch baselines. A baseline is a rule set: which patches auto-approve, filtered by classification (security, bugfix, critical update) and severity, plus an approval delay so a patch released this week does not install until it has had time to prove itself elsewhere. You can run the AWS-provided default baseline per OS or write your own.
- Maintenance windows or patch policies. A maintenance window schedules when Patch Manager is allowed to touch a given set of instances, and patch policies are the newer, higher-level way to apply a baseline, schedule, and scan/install behavior across a fleet without hand-building a window for every group.
- Scan vs. install. A scan operation reports what is missing against the baseline without changing anything on the instance. An install operation actually applies the approved patches. Running scan on a schedule and install only after a review gate is the difference between a dashboard and a surprise reboot.
- Compliance reporting. Patch Manager reports compliance state per instance and per patch, which is what answers the question "are we current" without someone manually SSHing into a fleet to check.
That is the complete feature set worth naming here, no more. The planning discipline behind it is older and broader than any one cloud console: NIST SP 800-40 Rev. 4 (Souppaya and Scarfone, April 2022) frames patching as preventive maintenance and covers planning across IT, OT, IoT, mobile, and cloud assets, not a single-cloud checklist. The point stands independent of which cloud you run: a baseline without a rollback plan is a liability, not a control.
Mutable patching vs. rebuilding the AMI
Patch Manager's scan/install model is built for mutable infrastructure: instances that live for weeks or months and get patched where they stand. That model has real limits.
Patch in place when:
- The fleet is small enough that per-instance drift is traceable.
- Instances are stateful or expensive to recreate on a schedule (a database node, a long-running worker).
- You need a fast, narrow fix for one CVE without touching the rest of the image.
Rebuild the AMI when:
- You run an Auto Scaling group and new instances should already be current the moment they launch, not patched after the fact.
- You want every instance in a fleet to be provably identical, which makes incident response and audit far simpler than reconciling drift across machines that have each been patched on their own schedule.
- The OS or base packages have accumulated enough change that an in-place patch run risks an unpredictable reboot sequence.
The immutable approach treats the AMI itself as the unit of change: bake a new golden image on a schedule or on a critical-CVE trigger, test it, then roll it out by replacing instances through the Auto Scaling group rather than patching the ones already running. Mutable patching fixes the instance you have. Immutable patching retires it and launches its replacement already fixed. Most mature fleets run both: Patch Manager for fast, narrow coverage between bakes, and a rebuild cadence for the baseline the fleet actually launches from.
A staged rollout, visualized
The shape that avoids both "patch everything in production at once" and "scan report nobody acts on" looks like this: scan continuously, approve through a baseline, install into a test tier first, verify, then promote the same build to production. Containers and Lambda run the equivalent pattern on their own tracks.
Containers are a separate patch surface: ECS and EKS
Patch Manager scans and installs on EC2 instances. It does not reach into a running container's filesystem, because a container image is a build artifact, not a node Systems Manager manages. ECS and EKS both run this as an immutable pattern by default: fix the base image, rebuild, push, redeploy. There is no "install" step on a live container the way there is on an EC2 instance.
For ECS, that means rebuilding the image against a patched base, publishing it to the registry, and redeploying so the service launches new tasks from the updated image while draining the old ones, a standard container-deployment pattern rather than anything Patch Manager touches. For EKS, the node side (the EC2 instances backing the cluster) still goes through the mutable-vs-immutable choice above, and the Kubernetes control plane and workload images are a parallel track with their own release cadence.
On that cadence: Kubernetes maintains release branches for the three most recent minor versions. Each minor release gets roughly 14 months of support under the Kubernetes patch release policy: about 12 months of regular patch releases, then about two months of maintenance mode limited to CVE fixes, dependency and base-image updates, and critical core issues, before end of life. Patch releases land monthly, with out-of-band releases when something is urgent. A version skew policy also limits how far components like kubelet and the API server are allowed to drift apart, which means you cannot let a cluster's control plane and nodes age at different speeds indefinitely and still expect support.
The practical consequence: track your EKS minor version against that 14-month window the same way you track CVE deadlines, and track node AMI rebuilds and workload image rebuilds as two separate jobs that happen to share a registry, even for teams running self-managed clusters rather than EKS, where the same base-image and node-patching discipline applies.
Lambda runtimes: patching you do not own and patching you do
Lambda splits patch responsibility in half. AWS patches the underlying execution environment and the managed runtime itself on its own schedule, which is not something Patch Manager touches and not something you configure a baseline for. What is yours: the function's declared runtime version, and everything in your deployment package or layer.
Two failure modes show up repeatedly:
- A function stays pinned to a runtime version AWS has deprecated. The function keeps running until it suddenly cannot be updated, or security patches for that runtime line stop shipping.
- A dependency bundled into the deployment package or a Lambda layer carries a known vulnerability that no amount of AWS-side patching touches, because it never leaves your package.
Both are fixed the same way: bump the declared runtime, rebuild the package against current dependencies, and redeploy a new function version. That is a dependency-and-build problem more than an infrastructure problem, which is why it belongs next to your SBOM and dependency-patching process rather than next to EC2 maintenance windows. See the SBOM and dependency-patching walkthrough for how that inventory-to-upgrade flow runs end to end.
An illustrative patch baseline check
The snippet below is an illustrative pattern, not a production script: it shows the shape of a boto3 call that creates a conservative patch baseline and then pulls compliance state back out, which is the loop a patch program actually runs on.
import boto3
from datetime import datetime
ssm = boto3.client("ssm")
## Illustrative pattern: a conservative baseline with an approval delay,
## so a patch has time to prove itself elsewhere before it auto-installs.
baseline = ssm.create_patch_baseline(
Name="prod-linux-conservative",
OperatingSystem="AMAZON_LINUX_2",
ApprovalRules={
"PatchRules": [
{
"PatchFilterGroup": {
"PatchFilters": [
{"Key": "CLASSIFICATION", "Values": ["Security"]},
{"Key": "SEVERITY", "Values": ["Critical", "Important"]},
]
},
"ApproveAfterDays": 3,
"ComplianceLevel": "CRITICAL",
}
]
},
)
baseline_id = baseline["BaselineId"]
## Scan only, no install, so a compliance report never doubles as a surprise reboot.
ssm.send_command(
DocumentName="AWS-RunPatchBaseline",
Parameters={"Operation": ["Scan"]},
Targets=[{"Key": "tag:Env", "Values": ["prod"]}],
)
report = ssm.list_compliance_items(
ResourceIds=["i-0123456789abcdef0"],
ResourceTypes=["ManagedInstance"],
)
for item in report["ComplianceItems"]:
print(item["Status"], item["Severity"], item["Details"])
The pattern worth keeping, independent of this exact API call: scan on a fixed cadence, approve through a baseline with a delay, install into a lower tier first, and let compliance reporting be the thing that tells you whether the install actually happened, rather than trusting that a cron job ran.
Where this falls apart without a program behind it
Everything above describes mechanics. None of it answers who watches the scan results, who decides a Critical CVE skips the three-day approval delay, or who rebuilds the AMI when a base-image vulnerability lands on a Friday. That is the part that actually fails in practice, and it is the part our vulnerability patching services are built around: asset and dependency inventory, continuous scanning across cloud and containers, CVSS-plus-active-exploit prioritization against signals like the CISA KEV list, and patch management with staging, testing, and rollback plans, rather than a one-off script.
For the urgent case, published response targets, not guarantees, apply: Critical issues acknowledged within 15 minutes, an engineer engaged within 1 hour, mitigation within 24 hours; High within 4 hours and patched within 7 days; Medium within 1 business day and patched within 30 days; Low on the next scheduled cycle, within 90 days. Those targets are measured from when an issue is reported or found by scanning, and exact coverage hours are agreed per plan. We work with the tools already named here, including AWS Systems Manager Patch Manager, Trivy, Grype, Snyk, Dependabot, and Renovate, inside the client's own environment and least-privilege access scope.
If you are weighing whether this belongs in-house or with a team that already runs the process, outsourced vs. in-house patching walks through that decision directly, and patch SLAs covers how to set response and remediation targets that hold up under audit.
The short version
Patch Manager automates OS-level patching on EC2 through baselines, maintenance windows or patch policies, scan-vs-install operations, and compliance reporting, exactly as documented by AWS. It does not reach into containers or Lambda. Treat AMI rebuilds and container image rebuilds as the immutable complement to in-place EC2 patching, track EKS against Kubernetes's roughly 14-month minor-version support window, and track Lambda runtime deprecation and your own bundled dependencies as a separate stream. The mechanics are documented; the discipline to run scan, approve, stage, and promote on every stream without a gap is the part most teams under-resource, which is the gap a dedicated patch program closes.
Frequently asked questions
- What is the difference between a patch baseline and a maintenance window in AWS Systems Manager?
- A patch baseline is the rule set that decides which patches get auto-approved, filtered by classification and severity with an approval delay. A maintenance window (or the newer patch policy) is the schedule that controls when Patch Manager is allowed to act on a given group of instances. One decides what; the other decides when.
- Does Patch Manager patch Docker containers running on EC2?
- No. Patch Manager operates on the EC2 instance's OS and some installed applications through the agent. A running container's filesystem is a build artifact, not a managed node, so container patching happens by rebuilding the image against a patched base image and redeploying, per the [AWS Systems Manager Patch Manager documentation](https://docs.aws.amazon.com/systems-manager/latest/userguide/patch-manager.html).
- How long does a Kubernetes minor version stay supported, and why does that matter for EKS?
- Per the [Kubernetes patch release policy](https://kubernetes.io/releases/patch-releases/), each minor version gets roughly 14 months total: about 12 months of regular monthly patch releases, then about two months of maintenance mode limited to CVE fixes and critical issues, then end of life. Running a cluster past that window means losing patch coverage, not just losing new features.
- Should I patch EC2 instances in place or rebuild the AMI?
- Patch in place for stateful or expensive-to-recreate instances and for fast, narrow fixes. Rebuild the AMI when you run an Auto Scaling group and want every new instance to launch already current, or when you need every instance in a fleet to be provably identical for audit and incident response.
- Who patches the Lambda runtime itself versus my function's code?
- AWS patches the underlying execution environment and the managed runtime. You are responsible for the declared runtime version your function targets and for everything bundled into your deployment package or layers, including third-party dependencies that never touch AWS's managed runtime at all.
Sources
The team behind Asaasin Engineering

Blend Berisha
Technical Lead / Engineering Lead

Doruntina Buzhala
Business Development Manager

Erin Abduli
Full-Stack Engineer

Florent Hoti
Co-Founder & CEO

Gentrit Hoti
Software Engineer

Hana Anadolli
Operations Manager

Krenar Mahmuti
AI Automations Specialist