Skip to content
intermediate Phase 18 · Advanced Cloud Operations

Cloud Automation

Automate operational tasks with Systems Manager, Lambda-based automation, and Runbooks for routine maintenance and incident response.

55m
0 problems
Topic Progress 0%

Systems Manager Automation and Runbooks

AWS Systems Manager provides a comprehensive automation platform for managing cloud infrastructure at scale. Systems Manager Automation executes runbooks, which are collections of steps that perform maintenance and deployment tasks across your AWS resources.

Runbooks are pre-defined or custom documents that define the actions Systems Manager performs on your resources. AWS provides over 100 pre-built runbooks for common tasks: patching instances, creating AMIs, cleaning up EBS snapshots, and remediating security findings. For example, the AWS-RunPatchBaseline runbook applies operating system patches to EC2 instances according to a defined maintenance window.

Custom Runbooks extend built-in functionality with organization-specific workflows. Create runbooks using YAML or JSON documents that define steps, input parameters, and outputs. Each step can invoke AWS APIs, execute scripts, or call Lambda functions. A custom runbook might automate application deployment: stop traffic to old instances, deploy new code, run health checks, and resume traffic.

Automation Executions track the progress of runbook runs. Each execution records inputs, outputs, step status, and error details. Implement approval steps in runbooks for high-risk operations requiring human confirmation before proceeding.

Parameter Store Integration allows runbooks to reference configuration data stored in Systems Manager Parameter Store or Secrets Manager. This separates configuration from automation logic, making runbooks reusable across environments.

Rate Controls limit the number of instances an automation executes against simultaneously. Use error thresholds to stop execution if failures exceed a percentage or count. For patching 1000 instances, configure a rate of 10% with an error threshold of 5% to patch in waves and stop if more than 5% fail.

Automation Patterns with Lambda and EventBridge

Combining Systems Manager with Lambda and EventBridge creates powerful automation patterns that respond to events, maintain compliance, and reduce operational overhead.

Automated Patching creates a maintenance window that defines when patching occurs, registers targets (EC2 instances by tag), and attaches the AWS-RunPatchBaseline runbook. Schedule using cron or rate expressions. For example, patch production servers every Sunday at 2 AM and development servers daily at midnight.

Compliance Automation uses AWS Config rules to detect non-compliant resources and Systems Manager Automation to remediate them. When Config detects an unencrypted EBS volume, it triggers a Systems Manager runbook that encrypts the volume automatically.

Lambda-Based Automation handles custom workflows. Lambda functions triggered by EventBridge rules can stop unused EC2 instances based on CloudWatch metrics, clean up old EBS snapshots, rotate access keys, or resize underutilized RDS instances.

EventBridge Rules enable both scheduled and event-driven automation. Scheduled rules use cron or rate expressions for recurring tasks. Event-driven rules react to AWS service events like EC2 state changes or S3 policy modifications. Combine rules with targets like Lambda, Systems Manager, SQS, or Step Functions.

Self-Healing Automation creates systems that automatically detect and recover from failures. CloudWatch alarms trigger EventBridge rules that invoke Lambda functions or Systems Manager automations. An unhealthy EC2 instance is automatically replaced. A failed ECS task is restarted.

Cost Optimization Automation identifies and acts on unused resources. Lambda functions can terminate unattached Elastic IPs, delete orphaned EBS volumes, stop stopped instances after 7 days, and right-size underutilized RDS instances, saving 20-30% on infrastructure costs.

Quiz

1. What are Systems Manager Runbooks?

Question 1 options

2. What do rate controls in Systems Manager Automation prevent?

Question 2 options

3. How does compliance automation work with Config and Systems Manager?

Question 3 options

4. Which service enables both scheduled and event-driven automation triggers?

Question 4 options

Flashcards

Question

What is a Systems Manager Runbook?

Answer

A document defining steps that perform maintenance and deployment tasks across AWS resources.

Question

What are rate controls?

Answer

Settings that limit simultaneous execution and set error thresholds to prevent automation failures.

Question

What is self-healing automation?

Answer

Systems that automatically detect failures via CloudWatch alarms and trigger recovery via Lambda or SSM.

Question

How does cost optimization automation work?

Answer

Lambda functions scheduled via EventBridge identify and clean up unused resources.

Revision Notes

Key Takeaways

  • 1. Systems Manager Runbooks define automated operational tasks
  • 2. Rate controls prevent automation failures from spreading
  • 3. EventBridge enables scheduled and event-driven automation
  • 4. Self-healing automation uses CloudWatch alarms for automatic recovery

Interview Tips

  • Design automated patching for 500 EC2 instances
  • Explain Config and Systems Manager compliance automation
  • Describe a self-healing architecture pattern
  • Discuss cost optimization automation strategies

Cheat Sheet

SSM: Runbooks + Automations + Rate Controls. Patterns: patching via maintenance windows, compliance via Config+SSM, self-healing via CloudWatch+EventBridge+Lambda, cost cleanup via scheduled Lambda.