Detecting and Remediating Non-Desired System State
Systems drift from their desired state through manual changes, failed deployments, misconfigurations and attacks. Mature operations detect the deviation quickly and return the system to the desired state automatically where it is safe, or route it to people where judgement is needed. This lesson brings together the detection sources, the remediation mechanisms, OpsCenter for operational work items and the design of remediation runbooks.
Learning outcomes
After completing this lesson, you will be able to:
- Identify the sources that detect non-desired state in resources, instances, stacks and security posture.
- Compare remediation mechanisms: Config remediation, State Manager, Security Hub automation rules and custom actions, and EventBridge workflows.
- Explain how Systems Manager OpsCenter and CloudWatch investigations support operational remediation.
- Describe the principles of safe, idempotent remediation runbooks and how recurrence is prevented.
Detecting Non-Desired State
A non-desired state is any difference between how a system should be and how it is. The difference can sit at several layers: an AWS resource whose settings break a rule, a stack whose resources were changed outside CloudFormation, an instance missing an agent or a patch, a security misconfiguration, or an application that is running but behaving abnormally. No single tool sees all of these layers. AWS Config sees resource settings but not the software inside an instance; State Manager sees an instance's software but not its security group; CloudWatch sees behaviour but not configuration.
Knowing which tool observes which layer is therefore the first step in choosing a remediation path, because the detecting tool usually also provides the natural way to fix the problem: a Config rule carries a remediation runbook, a State Manager association reapplies itself, and a drifted stack is corrected by a stack update. The table below maps each kind of deviation to the tool that detects it.
| Deviation | Detected by |
|---|---|
| Resource configuration violates a rule | AWS Config rules and conformance packs |
| Stack resources differ from templates | CloudFormation drift detection; the Config stack drift rule |
| Instance software or settings differ from the desired state | State Manager association compliance; Inventory with Config rules |
| Missing patches | Patch Manager compliance |
| Security misconfiguration or threat | Security Hub controls, GuardDuty findings, Inspector findings |
| Application behaviour is abnormal | CloudWatch alarms, anomaly detection, Application Signals SLOs |
| Control Tower baseline changed | Control Tower drift detection |
Which tool detects it?
Remediation Mechanisms
Each detection source has a natural remediation path.
AWS Config remediation
Automatic or manual SSM Automation runbooks attached to Config rules, with retries, as described in the AWS Config module. Suitable for resource configuration fixes.
State Manager reapplication
Associations reapply desired configuration on their schedule, so instance-level drift is corrected without any separate trigger.
CloudFormation
Updating the stack restores declared configuration for drifted properties; resolving drift by updating the template is appropriate when the manual change was intended.
Security Hub automation rules and custom actions
Automation rules in Security Hub update findings automatically when they match criteria, for example suppressing findings for an approved exception, raising the severity of findings in production accounts or assigning them to a team, which reduces noise before any remediation. Custom actions let analysts select findings in the console and send them to EventBridge, where a rule starts a remediation workflow, giving a human-in-the-loop option. Findings also arrive in EventBridge automatically for fully automated remediation.
EventBridge workflows
Any detection event can start Lambda functions, Automation runbooks or Step Functions workflows for responses that need logic, approvals or cross-account actions.
OpsCenter and Investigations
Not every deviation should be fixed automatically. Systems Manager OpsCenter collects operational work items called OpsItems, created from CloudWatch alarms, EventBridge rules, Config compliance changes, Security Hub findings or manually. Each OpsItem gathers related information, including resources, CloudTrail events, Config history and similar past OpsItems, and suggests relevant Automation runbooks that an operator can run from the OpsItem with one action. OpsItems can be aggregated across accounts in a delegated administrator account, and Systems Manager Explorer summarises them with other operational data. Since Systems Manager Incident Manager is closed to new customers, OpsCenter, combined with notification and paging tools, is the AWS-native place to track and resolve operational issues.
CloudWatch investigations use AI to analyse telemetry related to an alarm or an operator's question, including metrics, logs, traces, deployments and configuration changes, propose hypotheses for the root cause and suggest Automation runbooks for remediation, which shortens the diagnosis that precedes a manual or semi-automated fix.
Designing Remediation Runbooks
Remediation code changes production, often during stressful situations, so it follows strict principles, listed below.
- Idempotent: running twice has the same effect as once, because events can repeat.
- Verify before acting: check the current state and exit if the resource is already compliant or excepted, for example by an exception tag.
- Minimal blast radius: change only the non-compliant resource, with rate limits for bulk remediation.
- Reversible and recorded: record the previous state, for example in OpsItem notes or tags, so the change can be undone.
- Tested: runbooks are versioned, tested in non-production and exercised in game days.
- Tiered: low-risk, well-understood fixes run automatically; higher-risk fixes require approval through an aws:approve step or an analyst action.
Remediation also has a feedback loop. If the same deviation recurs, the root cause is upstream: a template that creates non-compliant resources, a missing preventive control or a process that bypasses the pipeline. The durable fix adds a preventive control, such as an SCP, a CloudFormation hook or a corrected template, so that remediation becomes rare.
Remediation principles
A Tiered Remediation Design
A company wants to handle configuration problems consistently: public S3 buckets in non-production must be fixed immediately; public buckets in production may be intentional and need review; unpatched instances must be patched in the next window; and operators should have a single place to see open issues.
-
Automatic tier
Config rule s3-bucket-level-public-access-prohibited with automatic remediation in non-production OUs, using a runbook that blocks public access unless an approved exception tag exists.
-
Review tier
In production, the compliance change event creates an OpsItem with the suggested runbook attached, and an operator runs it after review.
-
Scheduled tier
Patch compliance is restored by patch policies in the next maintenance window; instances still non-compliant afterwards create OpsItems.
-
Prevention
Recurring findings lead to an SCP and a Guard hook that block public bucket policies in non-production.
A security analyst wants to select specific Security Hub findings in the console and send them to a remediation workflow. Which Security Hub feature supports this?
Show answer
Custom actions. Selecting findings and choosing a custom action sends them to EventBridge, where a rule starts the remediation workflow.
Exam Tips
Remember for the exam
- Match detection to remediation: Config rules to SSM Automation remediation, State Manager compliance to reapplication, stack drift to stack updates, security findings to EventBridge workflows.
- Security Hub automation rules update findings automatically; custom actions send selected findings to EventBridge for human-initiated remediation.
- OpsCenter OpsItems aggregate context and suggest runbooks; use OpsCenter rather than Incident Manager, which is closed to new customers.
- Remediation runbooks must be idempotent, verify state first, limit blast radius and be tiered by risk; add preventive controls for recurring issues.