Lesson 3 of 4 Deployment Strategies and Infrastructure as Code

Operating and Patching Fleets with AWS Systems Manager

This lesson explains how AWS Systems Manager manages configuration, patching and operational tasks across large fleets of EC2 instances and on-premises servers in many accounts and Regions.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe how patch baselines approve patches and how patching is scheduled.
  • Describe how Run Command, State Manager and Automation operate fleets.
  • Identify the prerequisites for managed nodes.
  • Run one runbook across accounts and Regions.

Patching

Patch Manager decides which patches are approved through patch baselines, for example critical security updates seven days after release, which gives time for problems with a patch to surface, and installs them during maintenance windows with concurrency and error limits, so a bad patch is caught after a few instances. Patch policies created with Quick Setup apply consistent scanning and installation schedules to every account and Region in an organisation, with compliance reporting.

For fleets of interchangeable instances, the immutable alternative is often better: EC2 Image Builder produces patched, tested AMIs and container images on a schedule, and an Auto Scaling instance refresh or a new deployment replaces the running instances. Patch Manager is then used in scan mode to prove compliance rather than to install patches in place.

Fleet operations

Systems Manager provides the tools for operating large fleets. Run Command runs scripts on many instances at once, with rate controls and error thresholds. State Manager reapplies a defined configuration on a schedule, so drift is corrected. Automation runs multi-step runbooks, with approval steps, across accounts and Regions, which suits operational procedures such as patching an AMI or recovering an instance. Inventory collects data about installed software, and Distributor packages and installs agents.

Session Manager gives audited shell access without SSH keys, open inbound ports or bastion hosts. Parameter Store holds configuration, and AppConfig deploys configuration changes gradually, with validation and automatic rollback. OpsCenter tracks operational issues as OpsItems, with related resources and runbooks. The following table summarises the capabilities.

CapabilityWhat it does
Run CommandScripts on many instances with rate controls
State ManagerKeeps instances in a defined state on a schedule
AutomationMulti-step runbooks with approvals, across accounts and Regions
Inventory, DistributorSoftware data; packaging and installing agents
Session ManagerAudited shell access without SSH keys, open ports or bastions
Parameter Store, AppConfigConfiguration and gradual, validated config deployment
OpsCenterOperational issues (OpsItems) with related resources and runbooks

Prerequisites for managed instances

Systems Manager can act only on managed nodes, and an instance becomes managed only when three conditions are met: the SSM Agent is installed and running; the instance has credentials, through an instance profile with AmazonSSMManagedInstanceCore or through Default Host Management Configuration for the whole account; and it can reach the Systems Manager endpoints, through a NAT gateway or VPC endpoints. On-premises servers register as hybrid managed nodes through an activation. An instance missing from Systems Manager is diagnosed by checking these conditions in that order.

Worked example

One runbook across accounts and Regions

A critical OpenSSL vulnerability requires an emergency package update on every production instance, in 40 accounts and three Regions, within hours, without overloading any account. From the delegated administrator account, a single Automation execution fans out:

aws ssm start-automation-execution --document-name AWS-RunPatchBaseline \
  --target-parameter-name InstanceId --targets Key=tag:Env,Values=prod \
  --parameters Operation=Install,RebootOption=RebootIfNeeded \
  --max-concurrency 10% --max-errors 5% \
  --target-locations '[{
    "Accounts": ["ou-ab12-34cd5678"],
    "Regions": ["eu-west-1", "eu-central-1", "us-east-1"],
    "ExecutionRoleName": "AWS-SystemsManager-AutomationExecutionRole",
    "TargetLocationMaxConcurrency": "5",
    "TargetLocationMaxErrors": "2"
  }]'

Each target account needs the execution role, which is normally deployed in advance with a service-managed StackSet. Rate controls apply at two levels: how many account-Region pairs run at once, and how many instances within each. For immutable fleets, the equivalent response is to rebuild the golden AMI with Image Builder and start instance refreshes.

Check yourself

What makes an EC2 instance a Systems Manager managed node?

Show answer

The SSM Agent, permissions from an instance profile or the Default Host Management Configuration, and network access to the Systems Manager endpoints.

Exam Tips

Remember for the exam

  • To patch every account and Region from one place, use Quick Setup patch policies.
  • A golden AMI pipeline is built with EC2 Image Builder.
  • For audited shell access without bastions or SSH keys, use Session Manager.
  • To run a remediation across accounts and Regions, use Automation runbooks.
  • If an instance does not appear in Systems Manager, check the agent, the instance profile and the endpoints.