Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Below are step‑by‑step instructions using only the AWS Management Console, assuming you already have a CloudTrail trail logging management events in all regions to a CloudWatch Logs log group. If not, I’ll include the prerequisite steps first.
0. Prerequisite: Ensure CloudTrail is Logging to CloudWatch Logs
- Open CloudTrail console.
- Go to Trails in the left menu.
- Select your main trail (or create one if you don’t have it).
- In the trail details page, under CloudWatch Logs, choose Edit (or Configure).
- For CloudWatch Logs log group, either:
- Choose an existing log group, or
- Type a new log group name (e.g.,
/aws/cloudtrail/management).
- Select or create an IAM role as prompted to allow CloudTrail to write to CloudWatch Logs.
- Save changes and confirm events are being delivered (check the log group after a few minutes).
1. Create a Metric Filter for Network ACL Changes
- Open CloudWatch console.
- In the left navigation pane, select Logs → Log groups.
-
Click the log group where CloudTrail is sending logs (e.g.,
/aws/cloudtrail/management). - Select the Metric filters tab.
- Click Create metric filter.
-
In Filter pattern, paste:
- Click Next to test; choose a log event sample if available and verify it would match where appropriate.
- Click Next.
-
Under Assign metric, configure:
- Filter name:
NetworkACLChanges - Metric namespace:
Security/CloudTrail(or similar) - Metric name:
NetworkACLChangesCount - Metric value:
1 - Leave default for others unless you have a standard.
- Filter name:
- Click Next, then Create metric filter.
2. Create a CloudWatch Alarm on That Metric
- In CloudWatch, go to Alarms → All alarms.
- Click Create alarm.
- Click Select metric.
-
Navigate to your metric via:
- Browse → Security/CloudTrail (or your namespace) → Metrics with no dimensions (or the one you chose), then select
NetworkACLChangesCount.
- Browse → Security/CloudTrail (or your namespace) → Metrics with no dimensions (or the one you chose), then select
- Click Select metric.
-
Configure the metric and conditions:
- Statistic:
Sum - Period: e.g.,
5 minutes(or1 minuteif you want very fast alerts). - Threshold type:
Static - Whenever NetworkACLChangesCount is…
Greater than or equal to - Threshold value:
1.
- Statistic:
- Click Next.
-
Configure notification:
- Under Notification, choose In alarm.
- For Select an SNS topic:
- Choose an existing topic (e.g.,
security-alerts), or - Click Create new topic, give it a name, and enter your email address (or distribution list).
- Choose an existing topic (e.g.,
- Confirm subscription from the email if you created a new topic.
- Click Next.
-
Name and description:
- Alarm name:
NetworkACLChangesAlarm - Alarm description:
Alarm when any Network ACL is created, deleted, or modified.
- Alarm name:
- Review the configuration, then click Create alarm.
3. Validate
- Make a test NACL change (e.g., add a temporary rule in a test VPC).
- Wait for CloudTrail to deliver the log and CloudWatch to evaluate the metric (1–5 minutes, depending on your period).
- Confirm:
- The metric
NetworkACLChangesCountshows a data point > 0. - The alarm enters ALARM state.
- A notification is sent to your SNS subscribers.
- The metric
Using CLI
Using CLI
Below are the CLI-focused remediation steps to ensure you have a CloudWatch alarm on Network ACL changes (via CloudTrail logs).Assumptions (adjust names/regions as needed):
Attach permissions policy file Enable logging (if not already):
Then create the metric filter:
(Ensure the SNS topic exists and subscriptions are confirmed.)
- Region:
us-east-1 - Log group:
/aws/cloudtrail/netacl-logs - Metric name:
NetworkAclChanges - Metric namespace:
SecurityMonitoring - Alarm name:
NetworkAclChangesAlarm - SNS topic (for notifications):
arn:aws:sns:us-east-1:123456789012:SecurityAlerts
1. Ensure CloudTrail is logging to CloudWatch Logs
If you already have a CloudTrail configured to send logs to CloudWatch Logs, skip to step 2.1.1 Create a log group (if needed)
1.2 Allow CloudTrail to write to the log group (IAM role/policy)
Create an IAM role for CloudTrail (if you don’t have one). Example trust policy filetrust-policy.json:cloudtrail-cwlogs-policy.json:1.3 Create / update CloudTrail to use that log group
2. Create a CloudWatch Logs Metric Filter for NACL changes
Create a filter pattern filenacl-filter-pattern.txt:3. Create a CloudWatch alarm on the metric
Example: alarm when at least 1 NACL change occurs in a 5‑minute period.4. Validate
- Generate a test NACL change (e.g., add/remove an entry).
- Confirm:
- The CloudTrail event appears in the log group.
- The metric
NetworkAclChangesincrements. NetworkAclChangesAlarmtransitions toALARMand SNS notification is sent.
Using Python
Using Python
To fix this, you need to (1) ensure NACL changes are logged by CloudTrail, (2) create a CloudWatch Logs metric filter for those events, and (3) create a CloudWatch alarm on that metric. Below is a concise, step-by-step Python (boto3) example.Assumptions:
Ensure the IAM role has permissions to write to that log group.
Once this is in place, any NACL change recorded in CloudTrail will produce a CloudWatch metric data point and trigger the alarm, sending a notification via SNS.
- You already have:
- A CloudTrail trail delivering logs to a CloudWatch Logs log group (e.g.,
/aws/cloudtrail/logs) - An SNS topic ARN to notify (e.g.,
arn:aws:sns:us-east-1:123456789012:security-notifications)
- A CloudTrail trail delivering logs to a CloudWatch Logs log group (e.g.,
1. Make sure CloudTrail logs to CloudWatch Logs
If your trail is not yet configured to send to CloudWatch Logs:2. Create a CloudWatch Logs metric filter for NACL changes
Events to monitor (CloudTraileventName):CreateNetworkAcl, CreateNetworkAclEntry, DeleteNetworkAcl, DeleteNetworkAclEntry, ReplaceNetworkAclEntry, ReplaceNetworkAclAssociation3. Create a CloudWatch alarm on that metric
4. (Optional) Verify the configuration
You can list the metric filters and alarms to verify:Using Terraform
Using Terraform
- This creates a new metric filter and CloudWatch alarm, matching the provided CLI remediation.
- You must have an existing SNS topic for
EXISTING_SNS_TOPIC_ARN, and you must subscribe an endpoint (e.g., email) to that topic manually in AWS or via separate Terraform.
terraform plan should show:aws_cloudwatch_log_metric_filter.network_acl_changesto be created (or updated if it already exists but differs).aws_cloudwatch_metric_alarm.network_acl_changes_alarmto be created (or updated if it already exists but differs).

