Event-Driven Incident Response and Self-Healing
Overview
An incident is any unplanned interruption or degradation of service. Mature teams treat response as an engineering problem: detect quickly, notify the right people, gather evidence, apply a known fix and learn afterwards. On AWS, most of that chain can be automated with EventBridge, Systems Manager Incident Manager and Automation, Step Functions and Lambda.
Think of an aircraft: sensors detect trouble, the autopilot corrects what it safely can, and a checklist (runbook) tells the crew what to do when it cannot. Self-healing infrastructure is the autopilot; Incident Manager is the checklist, call tree and cockpit voice recorder in one.
The exam gives you a symptom (a failed deployment, a crashed instance, a leaked key, a throttled table) and asks for the most automated, lowest-effort response with the right blast radius. You need to recognise event sources, pick the executor (Lambda vs Automation vs Step Functions) and decide when a human approval or escalation is required.
Key Concepts
- Detect with CloudWatch alarms, GuardDuty/Config/Security Hub findings, AWS Health events and CloudTrail API events; route them with EventBridge.
- Systems Manager Automation runbooks (AWS-owned or custom YAML/JSON) run multi-step actions across accounts and Regions with approvals (
aws:approve), branching and rate control. - Incident Manager adds response plans, escalation plans, on-call schedules, engagement via SMS/voice/email, chat channels, a timeline and post-incident analysis.
- Step Functions orchestrates long-running, branching response workflows with retries, waits and human approval (task tokens).
- AWS Health events (for example EC2 scheduled retirement, Personal Health Dashboard) can be consumed via EventBridge; organisational view aggregates across accounts.
- OpsCenter manages OpsItems that link related resources, alarms and runbooks; alarms and EventBridge can create OpsItems automatically.
- AWS Chatbot (Amazon Q Developer in chat applications) posts notifications to Slack/Teams and runs approved CLI commands from chat.
- Safe automation uses least-privilege automation roles, rate limits, dry-run/notify-only phases and idempotent actions.
Detailed Notes
Response pipeline
| Phase | AWS tools |
|---|---|
| Detect | CloudWatch alarms, anomaly detection, GuardDuty, Config, Health, Synthetics |
| Route | EventBridge rules, SNS, composite alarms |
| Engage | Incident Manager response plan, escalation, Chatbot, PagerDuty/Opsgenie integrations |
| Diagnose | X-Ray, Logs Insights, CloudTrail, Automation diagnostic runbooks, Detective |
| Mitigate | Automation runbooks, Lambda, Step Functions, rollback in CodeDeploy/CloudFormation |
| Learn | Incident Manager analysis, Config timeline, CloudTrail Lake queries |
A custom Automation runbook
description: Restart a hung service and capture diagnostics
schemaVersion: "0.3"
assumeRole: "{{ AutomationAssumeRole }}"
parameters:
AutomationAssumeRole: { type: String }
InstanceId: { type: String }
mainSteps:
- name: captureDiagnostics
action: aws:runCommand
inputs:
DocumentName: AWS-RunShellScript
InstanceIds: ["{{ InstanceId }}"]
Parameters:
commands: ["ss -tanp > /tmp/conn.txt", "journalctl -u orders --since -10min > /tmp/orders.log"]
OutputS3BucketName: incident-evidence-111122223333
- name: approveRestart
action: aws:approve
inputs:
NotificationArn: arn:aws:sns:us-east-1:111122223333:approvals
Message: Restart orders on {{ InstanceId }}?
MinRequiredApprovals: 1
Approvers: [arn:aws:iam::111122223333:role/OnCallEngineer]
- name: restart
action: aws:runCommand
inputs:
DocumentName: AWS-RunShellScript
InstanceIds: ["{{ InstanceId }}"]
Parameters: { commands: ["systemctl restart orders"] }
- name: verify
action: aws:waitForAwsResourceProperty
timeoutSeconds: 300
inputs:
Service: ec2
Api: DescribeInstanceStatus
InstanceIds: ["{{ InstanceId }}"]
PropertySelector: "$.InstanceStatuses[0].InstanceStatus.Status"
DesiredValues: ["ok"]
Useful actions: aws:executeAwsApi, aws:invokeLambdaFunction, aws:branch, aws:createImage, aws:changeInstanceState, aws:executeStateMachine, aws:sleep. Automations can run cross-account and cross-Region using targets and an assume role, with concurrency and error thresholds for rate control.
EventBridge to Automation
aws events put-rule --name instance-status-failed \
--event-pattern '{"source":["aws.cloudwatch"],"detail-type":["CloudWatch Alarm State Change"],"detail":{"state":{"value":["ALARM"]},"alarmName":[{"prefix":"orders-hung-"}]}}'
aws events put-targets --rule instance-status-failed --targets \
Id=1,Arn=arn:aws:ssm:us-east-1:111122223333:automation-definition/RestartOrders:$DEFAULT,RoleArn=$EVENTS_ROLE
A CloudWatch alarm can also invoke an SSM OpsItem or Incident Manager response plan directly as an alarm action.
Incident Manager
| Component | Purpose |
|---|---|
| Response plan | Template: severity, engagement contacts, runbook, chat channel |
| Contacts and escalation plan | Who is engaged, and who next if no acknowledgement |
| On-call schedule | Rotations by time zone |
| Timeline and metrics | Evidence and time-to-acknowledge/mitigate |
| Post-incident analysis | Guided questions and action items |
Alarms and EventBridge rules start incidents by referencing a response plan, which runs the linked Automation document and opens a chat channel.
Self-healing patterns
| Failure | Automated remedy |
|---|---|
| Instance host failure | CloudWatch alarm recover action or ASG replacement |
| App hung but instance healthy | ELB health check marks unhealthy, ASG replaces; or Automation restarts service |
| Disk full | Alarm -> Automation expands EBS volume and filesystem |
| Lambda throttling | Raise reserved concurrency via runbook or scale downstream |
| DynamoDB throttling | Application Auto Scaling / on-demand mode |
| Failed deployment | CodeDeploy alarm rollback / CloudFormation rollback |
| Compromised credentials | EventBridge on GuardDuty finding -> disable keys, attach deny policy, notify |
| Public S3 bucket | Config rule + remediation enables Block Public Access |
| EC2 scheduled retirement | Health event -> stop/start instance via Automation |
Forensics and evidence
For suspected compromise: isolate (swap to quarantine security group, do not terminate), snapshot EBS volumes, capture memory if required, record CloudTrail and VPC flow data, attach a deny-all-by-token-time policy to the role session and preserve evidence in a write-only S3 bucket with Object Lock in the security account. AWS Config and CloudTrail Lake support timeline reconstruction.
Human in the loop
Fully automatic actions suit low-risk, reversible fixes. For risky ones use approval steps (Automation aws:approve, Step Functions task tokens, ChatOps approvals) and notify. Always include rollback/undo and idempotency; limit concurrency to avoid cascading failures from a runaway automation.
Metrics for improvement
Track MTTD, MTTA, MTTR, change failure rate and deployment frequency (the DORA metrics). Review incidents blamelessly and convert findings into new alarms, runbooks and guardrails.
Incident Manager workflow
| Element | Purpose |
|---|---|
| Response plan | Links an alarm or EventBridge rule to engagement, runbook and chat channel |
| Contacts and escalation | On-call rotation with SMS, voice and email, escalating after timeouts |
| Runbook | SSM Automation document executed during the incident |
| Timeline | Automatic recording of alarms, actions and notes |
| Post-incident analysis | Templates for impact, lessons and action items |
Keep severity definitions (SEV1-SEV4) with explicit response times, rehearse with game days and measure MTTD, MTTA and MTTR to show improvement.
Real World Example
Scenario: nightly pages for a hung worker service. The on-call engineer used to SSH in and restart a service. The team writes an Automation runbook that captures diagnostics to S3, restarts the service and verifies health, then links it to an Incident Manager response plan triggered by a composite alarm.
During business hours the runbook runs automatically; at night it requires approval from the on-call engineer through chat. Mean time to recovery falls from 25 minutes to 4, and every incident has an evidence trail for review.
Architecture Diagram
Detection feeds EventBridge, which engages people and runs runbooks.
- 1An alarm or finding detects the problem.
- 2EventBridge matches the event and starts a response plan.
- 3Incident Manager engages on-call and opens a chat channel.
- 4An Automation runbook captures diagnostics, requests approval and applies the fix.
- 5Evidence and timeline feed a post-incident review and new guardrails.
Best Practices
- ✓Write runbooks as code (Automation documents) and test them regularly.
- ✓Start with notify-only, then automate high-confidence, reversible fixes.
- ✓Use approval steps and rate limits for risky actions across many resources.
- ✓Capture evidence before remediation, and isolate rather than terminate compromised resources.
- ✓Run blameless reviews and track DORA metrics.
Common Interview Questions
Exam Tips
DOP-C02 focus
- "Run a predefined operational task automatically" = SSM Automation triggered by EventBridge.
- "On-call escalation, response plans, post-incident analysis" = Incident Manager.
- "Notified of AWS-side events affecting my resources" = AWS Health + EventBridge.
- Include approval (aws:approve) when the action is risky or irreversible.
Finished this lesson?
0 of 44 lessons done · 0% of the course

