Skip to main content
Welcome back. This article explains AWS Systems Manager Automation (SSM Automation) and how to use it to implement configuration changes in response to events. You’ll learn document structure, workflow controls, cross-account execution, IAM/trust requirements, integration patterns (EventBridge & AWS Config), monitoring, and best practices for production automation. Systems Manager Automation provides many built-in runbooks and also supports custom documents. Automation documents (runbooks) are authored in YAML or JSON and can be executed across accounts when IAM permissions and trust relationships are configured. Automations are event-driven and can be invoked from EventBridge, AWS Config, CloudWatch, SNS, Lambda, and other services.
A slide titled "AWS Systems Manager Automation" showing four colored panels that highlight features: 50+ AWS Runbooks, Custom Documents, Cross-Account Execution, and Event-Driven Integration. Each panel includes a short description of the feature (pre-built runbooks, YAML/JSON documents, centralized cross-account automation, and integration with EventBridge/CloudWatch).

Automation documents: structure and types

An Automation document (a runbook) defines metadata and the workflow to execute. Typical top-level fields include schemaVersion, description, parameters, and mainSteps. Documents live in the Systems Manager Documents section and can be invoked interactively or triggered by events. Each mainStep specifies the action type (for example, call an AWS API, run a script, or call another document) and its inputs. Use aws:runCommand, aws:executeAwsApi, aws:approve, and other built-in actions to build workflows.
A slide titled "Automation Documents: Structure and Types" showing a central blue circle labeled "Automation Documents" with four branches to boxes labeled "schemaVersion", "description", "parameters", and "mainSteps." The diagram visually outlines the main sections of an automation document.
AWS publishes many maintained automation documents for common operational tasks, such as patching, stopping/restarting EC2 instances, creating snapshots, and enabling S3 logging. These AWS-maintained runbooks are convenient for quick remediation and serve as templates for customization.
A slide titled "Automation Documents: Structure and Types" showing a circular diagram of AWS-maintained documents with five numbered items. The items listed are AWS-RunPatchBaseline, AWS-StopInstance, AWS-CreateSnapshot, AWS-RestartEC2Instance, and AWS-ConfigureS3BucketLogging.
Custom documents enable organization-specific remediation workflows. They can be multi-step, include conditional logic and error handling, call other documents, or integrate with third-party APIs and internal systems (monitoring, log providers, ticketing systems).
A presentation slide titled "Automation Documents: Structure and Types" showing a document-and-gear icon labeled "Custom Documents." It lists three features: organization-specific remediation workflows; multi-step operations with conditional logic and error handling; and integration with third-party APIs or internal systems.

Document actions and workflow controls

Automation supports multiple actions and control primitives to build robust runbooks:
  • API actions: call AWS APIs using aws:executeAwsApi.
  • Run Command actions: run commands on managed instances with aws:runCommand.
  • Script execution: run shell, PowerShell, or Python scripts.
  • Control flow: branching, wait/sleep, and approvals for human-in-the-loop workflows.
  • Error handling: onFailure and conditional branching to rollback or notify.
Common control constructs:
  • Branching — conditional if/else style logic to direct different paths.
  • Sleep/wait — insert delays between steps or poll for conditions.
  • Approvals — pause the workflow until human approvers accept or reject.
A presentation slide titled "Document Actions: Building Automation Logic." It shows three workflow control cards labeled "approve" (pause for human approval), "sleep" (add wait time between steps), and "branch" (apply conditional/if-else logic).

Cross-account automation

SSM Automation supports centralized cross-account remediation. A central automation account can run a document that modifies security groups, patches instances, or applies network ACLs across member accounts. This requires the central account to assume a role in the target account with the necessary permissions.
A diagram titled "Cross-Account Automation Architecture." A blue "Central Automation Account" box with a gear icon points via an arrow labeled "Executes remediation" to an orange "Target Accounts" box with a target/person icon.
When designing cross-account workflows, consider execution limits, scaling, and IAM trust:
A presentation slide titled "Cross-Account Automation Architecture" showing a three-colored gear labeled "IAM Requirements" with segments for Automation Document, Assume Role, and Target Account Role. A footer note warns "100 concurrent executions per account—use throttling or multiple accounts for large-scale remediation."
  • Systems Manager enforces an account-level limit on concurrent automation executions (for example, 100 concurrent executions). For very large scale remediation, implement throttling, batching, staging, or distribute executions across multiple accounts.
  • Central automation typically: detect → assume target role → execute remediation → log results centrally.
Be aware of account-level concurrent execution limits when planning large-scale remediation. Throttle or stage executions to avoid hitting limits.
A typical cross-account flow:
  1. AWS Config or an EventBridge rule detects a non-compliance or event.
  2. The event is routed to the central automation account.
  3. Central automation assumes an IAM role in the member account and performs remediation.
  4. Execution results are logged back to the central account for auditing.
A slide titled "Cross-Account Automation Architecture" showing a "How It Works" flow with four turquoise arrow icons labeled: AWS Config Detection, EventBridge Trigger, Assume Role, and Execute Remediation. Each step has a brief description (e.g., detect compliance violations, send event to central account, automation assumes target role, stop instance/modify SG/patch).
Centralized automation benefits:
  • Consistent remediation logic across accounts.
  • One document update applies everywhere.
  • Unified audit trail and centralized logging.
A slide titled "Cross-Account Automation Architecture" showing three benefit boxes: 1) Centralized Logic, 2) Simplified Updates, and 3) Unified Audit Trail. Each box has a colored numbered arrow and short notes about one document used across 50+ accounts, updates applying everywhere, and logs stored in a central account.

Human-in-the-loop (approval) workflows

For high-risk operations (deleting production databases, opening security groups to the world, terminating production instances, or other irreversible changes), add an approval step in mainSteps before the risky action. The runbook will pause, notify approvers (for example via SNS), and continue only after the configured number of approvals. If approval is denied or times out, branch to rollback or notification steps. A typical approval step:
A horizontal approval flow diagram titled "Approval Workflows for High-Risk Operations" with five numbered steps. The steps are: automation reaches approve step; notification sent to approvers; approvers review and respond; minimum approvals met → continue; denied/timeout → fail.
SSM integrates with SNS, email, or other notification channels to alert approvers and capture responses.
A slide titled "Approval Workflows for High-Risk Operations" showing five colored panels of use cases. Examples include deleting production databases, opening security groups to 0.0.0.0/0, terminating production EC2 instances, making config changes during peak hours, and executing irreversible operations without rollback.

Integration with EventBridge and AWS Config

A common and scalable pattern is to have AWS Config detect non-compliant resources and send a NON_COMPLIANT event to EventBridge. EventBridge then triggers an SSM Automation execution, passing contextual event data (resource IDs, account, region) into the runbook as parameters for targeted remediation.
  • Use EventBridge input transformers to map event fields into Automation parameters.
  • Filter events at the rule level to reduce unnecessary executions and cost.
A slide titled "Integration With EventBridge and AWS Config" showing Amazon EventBridge and AWS Config icons connected by a plus sign and an arrow that reads "Trigger automation when resources become NON_COMPLIANT." The slide also includes a small "© Copyright KodeKloud" in the bottom corner.

IAM and service trust requirements

IAM and service trust policies are central to successful Automation. Ensure the principals that start and run automations have required permissions and trust relationships.
  • Automation service role (used by Systems Manager during execution) must trust ssm.amazonaws.com.
  • If EventBridge triggers automation, the EventBridge role must trust events.amazonaws.com and have permissions to start automations.
  • The principal invoking automation requires ssm:StartAutomationExecution and ssm:GetAutomationExecution.
  • If your automation assumes or passes roles, the principal must also have iam:PassRole.
  • Instance profile roles used for Run Command must include AmazonSSMManagedInstanceCore or equivalent.
A presentation slide titled "IAM Requirements for Automation" showing a highlighted "Automation Service Role" box, a gear/automation icon, and two notes: "Used for running automation steps" and "Must trust ssm.amazonaws.com."
Critical permission examples:
A presentation slide titled "IAM Requirements for Automation" with a "Critical Permissions" header. Four labeled boxes list permissions: StartAutomationExecution, ssm:GetAutomationExecution, iam:PassRole, and service-specific (e.g., ec2, s3, rds) permissions.
Always include iam:PassRole for the principal that starts the automation if the Automation needs to assume or pass roles to other services. Missing iam:PassRole is a common cause of failures.

Common automation use cases

Typical uses for SSM Automation:
  • Patch management and OS updates (scheduled or on-demand).
  • Security remediation (close overly permissive security groups).
  • Provisioning and lifecycle management (create/delete resources).
  • Backup and snapshot orchestration.
  • Incident response and configuration drift remediation.

Monitoring and troubleshooting

Use the Systems Manager console to view automation execution status and step-level details. Execution logs can be sent to CloudWatch Logs and S3, and correlated with EventBridge events or OpsCenter incidents. Execution statuses:
A slide titled "Monitoring and Troubleshooting Automation" showing four monitoring tools: Systems Manager Console, CloudWatch Logs, EventBridge, and OpsCenter. Each tool has a short note on its role (view status/steps, review logs, catch failures/send alerts, and track recurring issues).
A slide titled "Monitoring and Troubleshooting Automation" that lists five execution statuses: Success, Failed, TimedOut, Cancelled, and Pending. Each status has a brief description of what it means (e.g., all steps completed, one or more steps failed, execution exceeded timeout, manual cancellation, waiting for approval).
Common causes of failures:
  • Missing or insufficient IAM permissions (ssm:*, iam:PassRole).
  • Target resources do not exist or are already in the desired state.
  • API throttling and service rate limits.
  • Long-running steps exceeding timeouts.
  • Approval timeouts when approvers are unavailable.
Troubleshooting tips:
  • Inspect step-level output in the SSM console.
  • Check CloudWatch Logs and S3 log archives for detailed output.
  • Correlate EventBridge events and Config records to understand triggers.
  • Re-run with increased logging or in a staging environment to reproduce.

Best practices

  • Test and validate runbooks in non-production first.
  • Use least-privilege IAM roles and scoped policies to reduce blast radius.
  • Version-control documents and tag both documents and executions for traceability.
  • Filter events at EventBridge rule level to avoid unnecessary executions and cost.
  • Throttle, batch, or stage large-scale remediations to stay within concurrent execution limits.
  • Persist execution logs to S3, build CloudWatch dashboards for trends, and track incidents in OpsCenter.
A slide titled "Production Automation — Best Practices" showing three checklist columns: Testing & Validation, Security Considerations, and Operational Excellence. Each column lists brief recommendations like test in non‑prod, use least‑privilege IAM and CloudTrail, and add tags and CloudWatch alarms.
That covers the essentials of AWS Systems Manager Automation: document structure, workflow controls, cross-account execution, IAM requirements, monitoring, and production best practices. Use Automation to codify repeatable, auditable, and centralized remediation and operational tasks.

Watch Video