Automatically Isolate Compromised EC2 Instances with AWS Config and Systems Manager
A company uses AWS Organizations with multiple accounts. The security team notices that an IAM user in the production account has been making changes to security group rules that are not compliant with the company's policy. The team wants to automatically revoke any non-compliant security group rules and notify the security team. What is the MOST efficient way to achieve this?
⚠ Common exam trap
It's easy for candidates to confuse detective controls (CloudTrail, CloudWatch alarms) with corrective controls (AWS Config remediation), and fail to recognize that SCPs are preventive and cannot selectively revoke existing non-compliant rules.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use an AWS Config managed rule to detect non-compliant security group rules, and configure an automatic remediation action with AWS Systems Manager Automation.
AWS Config managed rules can continuously evaluate security group rules against a desired policy (e.g., disallowing SSH from 0.0.0.0/0). When a non-compliant change is detected, AWS Config can trigger an automatic remediation action using an AWS Systems Manager Automation document that revokes the offending rule. This provides both detection and automated correction without manual intervention, making it the most efficient solution.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Create a CloudWatch alarm on the SecurityGroupEvent metric to notify the security team.
Why it's wrong here
A CloudWatch alarm on a SecurityGroupEvent metric is not a native CloudWatch metric; security group changes are recorded as API events through CloudTrail or EventBridge. Even if you created a custom metric or rule to trigger an alarm, the alarm can only notify the security team—it cannot automatically revoke or roll back the non-compliant security group rule, leaving a window of exposure until a human manually intervenes.
- ✗
Apply a Service Control Policy (SCP) that denies changes to security groups in the production account.
Why it's wrong here
An SCP is an organizational policy that denies or allows entire API actions, such as ec2:AuthorizeSecurityGroupIngress, for all principals in the account. It cannot inspect the content of the security group rule (for example, whether port 22 is open to 0.0.0.0/0) to block only non-compliant changes, and it does not remediate existing non-compliant rules, meaning legitimate changes would also be blocked while the offending rule remains active.
- ✗
Set up a CloudTrail trail that logs security group modifications and use Amazon Detective to analyze the changes.
Why it's wrong here
A CloudTrail trail captures all API activity, including security group modifications, and Amazon Detective can help investigate the source and scope of those changes after the fact. However, this approach is purely detective: it produces logs and analysis but has no built-in mechanism to automatically apply a corrective action or restore the security group to a compliant state, so the security exposure persists until a human runs a fix.
- ✓
Use an AWS Config managed rule to detect non-compliant security group rules, and configure an automatic remediation action with AWS Systems Manager Automation.
Why this is correct
AWS Config's managed rules continuously evaluate security group configurations against policies such as 'restricted-ssh' or 'vpc-sg-open-only-to-a-specific-port'. When a rule detects a non-compliant inbound rule, a configured AWS Systems Manager Automation document, such as AWS-DisablePublicAccessForSecurityGroup, automatically removes or tightens the offending rule, providing the required detect-and-remediate control loop without manual intervention.
Go deeper
Related to this question
About these practice questions
One of 1,298 original DOP-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on DOP-C02
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A company uses AWS Organizations with multiple accounts. The security team needs a centralized solution to detect and respond to EC2 instances that are publicly accessible with SSH open to 0.0.0.0/0. Which combination of services provides the most automated detection and remediation?
hard- A.AWS CloudTrail and Amazon EventBridge
- B.Amazon GuardDuty and AWS Lambda
- C.AWS Config and Amazon Simple Notification Service (SNS)
- ✓ D.AWS Config and AWS Systems Manager Automation
Why D: AWS Config and AWS Systems Manager Automation together provide automated detection and remediation. AWS Config rules can detect EC2 instances with security groups that allow SSH from 0.0.0.0/0, and the rule can trigger an SSM Automation document to remediate the issue, such as by modifying the security group or stopping the instance. This combination is centralized and works across multiple accounts in AWS Organizations when Config and SSM are configured with a delegated administrator.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DOP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DOP-C02 exam.