Lesson 2 of 4 Operational Excellence and Observability

Automating Remediation Across Accounts

This lesson explains how automation shortens recovery and removes toil, with well-understood fixes running automatically everywhere and risky fixes waiting for approval.

Learning outcomes

After completing this lesson, you will be able to:

  • Identify the four remediation paths.
  • Choose good candidates for automatic remediation.
  • Explain how automation runs across accounts and Regions.
  • Decide which fixes need approval.

Remediation paths

Automated remediation follows four paths, depending on what detects the problem. AWS Config rules and conformance packs can remediate non-compliant resources automatically through Systems Manager Automation runbooks, with retries and an audit trail, for example re-enabling encryption on a bucket. EventBridge rules match events from many sources: CloudTrail API calls, AWS Health events, GuardDuty and Security Hub findings, alarm state changes and Config changes. They invoke Lambda, Step Functions or SSM Automation in response.

CloudWatch alarms act directly: they can recover or reboot EC2 instances, run Auto Scaling policies, notify SNS or create OpsItems. Security Hub automation rules update finding fields, such as severity and workflow status, as findings arrive, so the automation that follows acts on accurate data. The following table summarises the paths.

TriggerAction
AWS Config rules and conformance packsAutomatic remediation through Systems Manager Automation runbooks, with retries and an audit trail
EventBridge rulesMatch CloudTrail API events, AWS Health events, GuardDuty and Security Hub findings, alarm state changes and Config changes; invoke Lambda, Step Functions or SSM Automation
CloudWatch alarmsAlarm actions run EC2 actions (recover, reboot), Auto Scaling policies, SNS notifications or Systems Manager OpsItems
Security Hub automation rulesUpdate finding fields (severity, workflow status) as findings arrive, before downstream automation runs

Typical automated fixes

The best candidates for automatic remediation are fixes that restore a known good state. Re-enabling CloudTrail, AWS Config or default EBS encryption when someone disables them, removing a security group rule that opens SSH or RDP to the internet, and turning Block Public Access back on for a bucket that has been made public all return a resource to its required configuration, and none of them can break a correctly built workload.

Operational and security responses follow the same pattern. A compromised instance is isolated by swapping its security groups for a quarantine group, and its volumes are snapshotted for forensic analysis before anything else changes. A failed service is restarted, or an unhealthy instance replaced, by a runbook triggered from its alarm.

Running automation across accounts

Systems Manager Automation runbooks can run in many accounts and Regions from a central account, with rate controls and error thresholds. Config remediation and EventBridge rules are deployed with StackSets or conformance packs so that every account, including new ones, has the same automatic fixes. Events from member accounts can also be sent to a central event bus and remediated from one place.

Deciding what to automate fully

Not every remediation should run without a person. A fix is automated fully when it is deterministic, reversible and cannot break a workload, such as enabling logging or encryption. When a fix could cause an outage, such as stopping an instance or revoking a role that an application uses, the runbook still automates the work but waits for approval, through an aws:approve step in a Systems Manager Automation runbook or a task-token callback in Step Functions.

Every automated action is recorded, in the Automation execution history, CloudTrail and the related OpsItem or ticket, so engineers and auditors can see what changed, when and why. A remediation that fires repeatedly for the same cause is a signal to add prevention, such as an SCP or a proactive control, so the problem stops occurring.

Worked example

Turning logging back on automatically

Someone with administrator access stops a CloudTrail trail in a member account. The SCP should have prevented it, but defence in depth requires detection and automatic repair as well. An EventBridge rule matches the API call recorded by CloudTrail:

{
  "source": ["aws.cloudtrail"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": { "eventSource": ["cloudtrail.amazonaws.com"], "eventName": ["StopLogging", "DeleteTrail"] }
}
import boto3

def handler(event, context):
    trail = event["detail"]["requestParameters"]["name"]
    if event["detail"]["eventName"] == "StopLogging":
        boto3.client("cloudtrail").start_logging(Name=trail)
    actor = event["detail"]["userIdentity"]["arn"]
    boto3.client("sns").publish(TopicArn=SECURITY_TOPIC,
        Subject="CloudTrail tampering reverted",
        Message=f"{actor} called {event['detail']['eventName']} on {trail}; logging restored.")

The function restores logging within seconds and tells the security team who made the change. A deleted trail cannot simply be restarted, which is why the notification matters and why the organisation trail, which member accounts cannot delete, is the primary control.

Check yourself

Why do some remediations keep an approval step?

Show answer

High-impact changes, such as stopping production instances, need a human decision. Automation runbooks can include an approval step before acting.

Exam Tips

Remember for the exam

  • To fix non-compliant resources automatically, use a Config rule with SSM Automation remediation.
  • To react to API calls or findings, use EventBridge rules that invoke Lambda, Step Functions or Automation.
  • Deploy remediation to every account with StackSets or conformance packs.
  • For approval before a risky automated change, add an Automation approval step.
  • Fully automate only fixes that are safe and deterministic.