Incident and Event Response · Topic 3 of 5
Automated Remediation and Configuration Changes
Respond to events with automated changes using Config remediation, EventBridge, Systems Manager Automation, Lambda, lifecycle hooks and instance isolation.
- 5 min
- Config remediation attaches an SSM Automation document to a rule, with manual or automatic execution.
- The remediation role is set in the assume role parameter and should be least privilege.
- EventBridge rules turn findings and state changes into runbook or function executions.
What it is
Automated remediation means a system detects a problem or a trigger and changes configuration by itself: closing an open port, replacing a compromised instance, scaling a service or updating a record. It shortens the time between detection and fix from hours to seconds.
The pattern is always detect, decide, act and record. Detection comes from an alarm, a Config rule or a finding. The action is a Systems Manager Automation runbook, a Lambda function or an Auto Scaling operation.
How it works
Remediation with AWS Config
A Config rule evaluates resources and marks them noncompliant. A remediation action attaches a Systems Manager Automation document to the rule, and it can run automatically or by manual approval.
aws configservice put-remediation-configurations --remediation-configurations '[{
"ConfigRuleName": "restricted-ssh",
"TargetType": "SSM_DOCUMENT",
"TargetId": "AWS-DisablePublicAccessForSecurityGroup",
"Automatic": true,
"MaximumAutomaticAttempts": 3,
"RetryAttemptSeconds": 60,
"Parameters": {
"GroupId": {"ResourceValue": {"Value": "RESOURCE_ID"}},
"AutomationAssumeRole": {"StaticValue": {"Values": ["arn:aws:iam::111122223333:role/ConfigRemediationRole"]}}
}
}]'
The remediation runs with the assume role named in the parameters, so that role needs only the permissions the fix requires. Use this approach for compliance drift, such as public buckets, open security groups and unencrypted volumes, because the rule continues to check after the fix.
Remediation with EventBridge
For events that Config does not cover, match an event and call a target. Here, a rule reacts to a high severity GuardDuty finding.
{
"source": ["aws.guardduty"],
"detail-type": ["GuardDuty Finding"],
"detail": {"severity": [{"numeric": [">=", 7]}]}
}
A Lambda or Automation target can then isolate the instance: replace its security groups with an isolation group that allows no inbound or outbound traffic, snapshot its volumes for forensics, tag it, and notify the security team. Isolating, not terminating, keeps the evidence.
Systems Manager Automation as the action engine
Automation runbooks give audited, repeatable actions with approval steps, branching and rate control. AWS provides many documents for common fixes, and your own can call any AWS API through aws:executeAwsApi. Runbooks can be triggered by EventBridge, Config, alarms, maintenance windows or by hand.
| Action engine | Best for |
|---|---|
| SSM Automation | Standard, audited fixes with approvals and many targets |
| Lambda | Custom logic or integration with outside systems |
| Step Functions | Multi step remediation with waits and human steps |
| Auto Scaling policy | Capacity changes |
Responding to lifecycle events
Auto Scaling lifecycle hooks pause an instance during launch or termination and publish an event. A rule can run a function or a runbook while the instance waits, for example to register it with a service, pull configuration, or drain connections and upload logs before termination. The hook ends when the action completes, or when the timeout expires.
aws autoscaling complete-lifecycle-action --lifecycle-hook-name launch-hook \
--auto-scaling-group-name web-asg --lifecycle-action-result CONTINUE \
--instance-id i-0123456789abcdef0
Other common event to change patterns
| Event | Automated change |
|---|---|
| Alarm on queue backlog | Scale consumers out |
| Instance launch | Add a DNS record or register in a service catalog |
| New object in S3 | Process, scan or move the object |
| Config noncompliance | Fix the resource |
| Security Hub finding with a custom action | Run a chosen response on demand |
| CodePipeline failure | Open a ticket or roll back |
| Parameter Store change | Trigger a deployment that reads the new value |
Safe automation
- Give each remediator a least privilege role and restrict what it can touch with tags or conditions.
- Make actions idempotent, so a repeat does no harm.
- Guard against loops: a fix that creates a new event should not retrigger itself endlessly.
- Start with notify only, then enable automatic fixes when you trust the rule.
- Add rate limits, approval steps for destructive actions and a clear audit trail through CloudTrail and notifications.
Fixing at the source
Remediation treats symptoms. Pair it with a preventive control, such as an SCP or a CloudFormation Hook, and fix the template that created the bad resource, or the drift will return.
What to remember for the exam
- Config remediation attaches an SSM Automation document to a rule, with manual or automatic execution.
- The remediation role is set in the assume role parameter and should be least privilege.
- EventBridge rules turn findings and state changes into runbook or function executions.
- Isolate a compromised instance with a restrictive security group and snapshots instead of terminating it.
- Lifecycle hooks let you run actions before an instance joins or leaves service.
- SSM Automation provides approvals, rate control and audit; Lambda gives custom logic.
- Use Step Functions for long remediation with waits and human steps.
- Combine detective remediation with preventive controls and template fixes.
For a compliance rule that must fix resources automatically with the least custom code, use Config with an SSM Automation remediation.
Common mistakes
Terminating a compromised instance at once. The memory and disk evidence is lost.
Granting remediation roles broad admin rights. A bug or abuse can then change anything.
Automating destructive fixes first. A wrong rule deletes valid resources, so start with notify and approve.
Ignoring the loop risk. An automation that creates findings or changes can retrigger itself.
An automatic remediation that closes access can also cut off a legitimate administrator or an application, so test rules against a copy of the environment.
Check yourself
How does AWS Config fix a noncompliant resource automatically?
A remediation action runs a Systems Manager Automation document, using a role you provide.
What should you do with a compromised instance for forensics?
Isolate it with a restrictive security group and snapshot its volumes before any termination.
What can a lifecycle hook do for an instance that is launching?
Pause it in a wait state so a function or runbook can configure it before it enters service.
Topic 3 of 5 in Incident and Event Response
Test yourself on Incident and Event Response
The full AWS DOP-C02 question bank has 844 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by AWS. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.