Automating Procedures with Systems Manager Runbooks
This lesson explains Systems Manager Automation runbooks, documents that describe a sequence of steps against AWS resources and managed nodes, which turn procedures into repeatable, auditable actions.
Learning outcomes
After completing this lesson, you will be able to:
- Identify AWS-provided runbooks.
- Describe runbook structure and actions.
- Grant Automation the permissions it needs.
- Decide between predefined and custom runbooks.
AWS-provided runbooks
AWS publishes hundreds of runbooks, owned by Amazon and named with the prefixes AWS-, AWSSupport-, AWSConfigRemediation- and AWSEC2-. They cover common tasks such as restarting, stopping or resizing instances, creating AMIs and snapshots, enabling encryption, restricting security groups and troubleshooting connectivity. Using a predefined runbook is almost always the least-effort answer when one exists. The following table lists runbooks that appear frequently in operations scenarios.
| Runbook | Purpose |
|---|---|
| AWS-RestartEC2Instance / AWS-StopEC2Instance | Restart or stop instances |
| AWS-CreateImage / AWS-CreateSnapshot | Create an AMI or EBS snapshot |
| AWS-ResizeInstance | Change an instance type (stop, modify, start) |
| AWS-UpdateLinuxAmi / AWS-UpdateWindowsAmi | Patch an AMI and create a new one |
| AWSSupport-TroubleshootSSH / AWSSupport-ExecuteEC2Rescue | Diagnose and repair unreachable instances |
| AWSSupport-TroubleshootManagedInstance | Find why a node is not managed by Systems Manager |
| AWS-DisablePublicAccessForSecurityGroup | Remove open SSH and RDP rules |
| AWSConfigRemediation-EnableS3BucketEncryption and similar | Fix resources reported by AWS Config rules |
Runbook structure
A runbook is a YAML or JSON document with schemaVersion: '0.3', an optional assumeRole, parameters and a list of mainSteps. Each step uses an action. The most important actions are aws:executeAwsApi (call any AWS API and capture outputs), aws:runCommand (run a Command document on nodes), aws:executeScript (run Python or PowerShell inline), aws:waitForAwsResourceProperty and aws:assertAwsResourceProperty (wait for or check a state), aws:branch (choose the next step), aws:approve (pause for human approval), aws:sleep, aws:invokeLambdaFunction, aws:executeAutomation (call another runbook) and aws:createImage. Steps have onFailure and maxAttempts settings, and outputs from one step can feed later steps.
schemaVersion: '0.3'
description: Snapshot the root volume, then restart the instance
assumeRole: '{{ AutomationAssumeRole }}'
parameters:
InstanceId: {type: String}
AutomationAssumeRole: {type: String}
mainSteps:
- name: getRootVolume
action: aws:executeAwsApi
inputs:
Service: ec2
Api: DescribeInstances
InstanceIds: ['{{ InstanceId }}']
outputs:
- Name: VolumeId
Selector: $.Reservations[0].Instances[0].BlockDeviceMappings[0].Ebs.VolumeId
Type: String
- name: snapshot
action: aws:executeAwsApi
inputs: {Service: ec2, Api: CreateSnapshot, VolumeId: '{{ getRootVolume.VolumeId }}'}
- name: approve
action: aws:approve
inputs: {Approvers: ['arn:aws:iam::111122223333:role/OpsLead'], MinRequiredApprovals: 1}
- name: restart
action: aws:executeAutomation
inputs: {DocumentName: AWS-RestartEC2Instance, RuntimeParameters: {InstanceId: ['{{ InstanceId }}']}}The following diagram shows a runbook's steps and the settings around them.

Runbook actions
Permissions for Automation
An Automation execution runs either with the permissions of the user who started it or with an assume role passed as the AutomationAssumeRole parameter. The assume role's trust policy must allow ssm.amazonaws.com, its permissions must cover every API the runbook calls, and the person or service starting the runbook needs iam:PassRole for it. Using an assume role lets operators run a tightly scoped procedure, such as restarting instances, without holding the underlying permissions themselves. EventBridge targets, Config remediation and State Manager associations always require an assume role.
Runbook permission errors
Choosing between predefined and custom
An operations team wants a one-click way to stop an unresponsive instance, take a snapshot of its volumes and start it again. No single AWS runbook does all three, but each step exists. A custom runbook with aws:executeAutomation steps calling AWS-StopEC2Instance, AWS-CreateSnapshot for each volume and AWS-StartEC2Instance reuses tested building blocks instead of reimplementing them in a script. The runbook is shared with the organisation's other accounts through document sharing.
Which runbook action pauses until a person approves?
Show answer
aws:approve.
Exam Tips
Remember for the exam
- Prefer an AWS-provided runbook when one does the job.
- aws:executeAwsApi calls any API; aws:runCommand runs commands on nodes; aws:approve waits for a human.
- The assume role must trust ssm.amazonaws.com and the caller needs iam:PassRole.
- Runbooks can call other runbooks with aws:executeAutomation.