Lesson 4 of 5 AWS Systems Manager

Automating Patch Management with Patch Manager

Unpatched systems are one of the most common causes of security incidents, and manual patching does not scale. Systems Manager Patch Manager automates scanning for and installing operating system and application patches across Linux, Windows and macOS nodes. This lesson explains patch baselines, patch policies and patch groups, scan and install operations, reboot behaviour, scheduling and compliance reporting.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain how patch baselines define which patches are approved, including auto-approval delays and rejected patches.
  • Distinguish between patch policies created with Quick Setup and the older patch group approach.
  • Describe the scan and install operations of AWS-RunPatchBaseline, reboot options and hooks.
  • Explain how patch compliance is reported and aggregated across accounts.

Patch Baselines

A patch baseline defines which patches are approved for installation on a set of nodes. AWS provides a predefined default baseline for each operating system, such as AWS-AmazonLinux2023DefaultPatchBaseline and AWS-DefaultPatchBaseline for Windows, which approves critical and important security updates after a short delay. Custom baselines give control through the following settings.

  • Approval rules select patches by product, classification (for example Security or Bugfix) and severity (for example Critical or Important), and approve them automatically a number of days after release (ApproveAfterDays) or up to a specific date (ApproveUntilDate). An approval delay gives time for patches to be tested in non-production first.
  • Approved patches: specific patches approved regardless of the rules.
  • Rejected patches: patches that must not be installed, with an action of BLOCK (never install, even as a dependency) or ALLOW_AS_DEPENDENCY.
  • Compliance level: the severity reported when an approved patch is missing, such as CRITICAL or HIGH.
  • Patch sources (Linux): alternative repositories, such as an internal mirror.

A common practice is a delay of 0 days for development and 7 days for production, so that production receives only patches that have been running in development for a week.

The following diagram follows one patch through two baselines with different approval delays.

How approval delays in patch baselines stage a patch. A patch released on day 0 is approved at once by a development baseline with ApproveAfterDays of 0 and installed in that environment's next maintenance window. The production baseline approves it after 7 days, so production receives only patches that have run in development for a week. The compliance level sets the severity reported when an approved patch is missing.
The approval delay gives non-production time to test each patch.

Patch Policies and Patch Groups

Patch Manager offers two ways to decide which baseline applies to which nodes and when patching runs.

Patch policies (recommended)

A patch policy is created with Quick Setup and defines the baselines to use for each operating system, a scan schedule, an install schedule, reboot behaviour and targets, which can be accounts and Regions across an organisation, OUs, tags or resource groups. Quick Setup deploys the underlying associations and roles to every target account. Patch policies give centralised, organisation-wide patching from a single configuration.

Patch groups (older approach)

A patch group associates nodes with a baseline through a tag with the key Patch Group or PatchGroup. Each patch group is registered with one baseline per operating system, and patching is scheduled separately with maintenance windows or State Manager. Nodes without the tag use the default baseline. Patch groups work per account and Region, so they require more setup in multi-account environments.

Patch policies
Configured withQuick Setup
ScopeOrganisation, OUs, accounts and Regions
SchedulingBuilt into the policy
Choose when New, multi-account patching programmes.
Patch groups
Configured withTags, baselines and maintenance windows or associations
ScopeOne account and Region
SchedulingSeparate maintenance windows or associations
Choose when Existing per-account configurations.

Scanning, Installing and Rebooting

Patching is performed by the AWS-RunPatchBaseline document, which works on every supported operating system. Its Operation parameter is either Scan, which compares installed patches with the baseline and reports missing patches without changing anything, or Install, which installs missing approved patches. A common design runs Scan daily, so that compliance is always current, and Install weekly in a maintenance window.

The RebootOption parameter is RebootIfNeeded (the default), which reboots when installed patches require it, or NoReboot, which leaves the node in a pending reboot state that is reported as non-compliant until it restarts. AWS-RunPatchBaselineWithHooks adds pre-install, post-install and post-reboot hooks, which run documents such as stopping an application, removing the instance from a load balancer before patching and checking health afterwards.

For instances behind a load balancer in an Auto Scaling group, patching in place is one option; another is to patch the golden AMI with EC2 Image Builder and replace instances with an instance refresh, which avoids reboots in production. The choice depends on whether instances are disposable.

True or false

Patch Manager behaviour

Exam skills 2.3.1 · 2.3.4

Check four facts about patch baselines and AWS-RunPatchBaseline.

Log in to try this activity Interactive activities are free with an account.

Patch Compliance Reporting

Each scan or install records patch compliance for the node: compliant, or non-compliant with counts of missing, failed and pending-reboot patches by severity. Compliance data appears in Patch Manager, in Systems Manager Compliance and, through Systems Manager Explorer, aggregated across accounts and Regions. AWS Config records it as AWS::SSM::PatchCompliance, and the managed rule ec2-managedinstance-patch-compliance-status-check evaluates it. Compliance reports can be exported to S3 on demand or on a schedule for auditors, and a Resource Data Sync, described in the next lesson, can aggregate compliance for Amazon Athena queries. Security Hub can receive patch compliance findings from Patch Manager.

Worked example

An Organisation Patching Programme

An organisation must install critical and important security patches on production instances within 14 days of release, after at least 7 days in non-production, and must report compliance to auditors monthly. Instances run Amazon Linux 2023 and Windows Server in 60 accounts.

  1. Baselines

    Create custom baselines for each OS: non-production approves security patches of critical and important severity after 0 days; production after 7 days, with compliance level CRITICAL.

  2. Policies

    Create two patch policies with Quick Setup, targeting the NonProd and Prod OUs, with daily scans and a weekly install in a maintenance period, RebootIfNeeded.

  3. Hooks

    For stateful application servers, use AWS-RunPatchBaselineWithHooks to stop the application before installation and verify it after reboot.

  4. Reporting

    Aggregate compliance in Explorer from the delegated administrator and schedule a monthly compliance report export to S3.

Check yourself

Patching is run with RebootOption NoReboot. Why do nodes appear as non-compliant afterwards even though the patches were installed?

Show answer

Patches that require a reboot are reported as installed pending reboot until the node restarts, and pending-reboot patches count as non-compliant.

Exam Tips

Remember for the exam

  • Patch baselines approve patches by classification and severity with ApproveAfterDays delays; rejected patches can be blocked.
  • Patch policies (Quick Setup) configure baselines, schedules and targets across an organisation; patch groups use the Patch Group tag per account and Region.
  • AWS-RunPatchBaseline Scan reports compliance without changes; Install applies patches; RebootIfNeeded is the default; NoReboot leaves nodes pending reboot.
  • Use AWS-RunPatchBaselineWithHooks for pre-install and post-reboot actions; consider AMI replacement for disposable instances.
  • Patch compliance appears in Compliance, Explorer, AWS Config and Security Hub.