Skip to main content

More Info:

AWS VPCs configuration changes should be monitored using CloudWatch alarms.

Risk Level

Medium

Address

Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • AWS Well Architected Framework
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS AWS
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • Cloudanix Best Practice
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • HIPAA
  • HITRUST CSF
  • ISO 27001
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST
  • NIST CSF
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • SOC2
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

Below are the exact AWS Console steps to enable a “VPC Changes” alarm in CloudWatch.

Prerequisite: Make sure CloudTrail is sending logs to CloudWatch Logs

  1. In the AWS Console, go to CloudTrail.
  2. In the left menu, select Trails.
  3. Click your trail name (or create one if none exist).
  4. Under CloudWatch Logs, ensure:
    • CloudWatch Logs log group is set (e.g., /aws/cloudtrail/logs).
    • If not set:
      • Click Edit.
      • In CloudWatch Logs, choose Enabled.
      • Select or create a Log group.
      • Choose or create an IAM role as prompted.
      • Save the changes.

Step 1: Go to CloudWatch Logs

  1. Open CloudWatch in the AWS Console.
  2. In the left menu, choose LogsLog groups.
  3. Click the log group used by CloudTrail (e.g., /aws/cloudtrail/logs).

Step 2: Create a Metric Filter for VPC Changes

  1. Inside the log group, go to the Metric filters tab.
  2. Click Create metric filter.
  3. For Filter pattern, use a VPC-change pattern, for example:
    (You can reduce or expand this list depending on exactly which VPC events you want.)
  4. Click Next.
  5. Under Assign metric, configure:
    • Filter name: VPC-Changes-Filter
    • Metric namespace: Security/VPC
    • Metric name: VPCChanges
    • Metric value: 1
  6. Click Next, then Create metric filter.

Step 3: Create a CloudWatch Alarm for This Metric

  1. Still in CloudWatch, in the left menu, select AlarmsAll alarms.
  2. Click Create alarm.
  3. Click Select metric.
  4. Navigate to the metric:
    • Custom namespaces → choose Security/VPC.
    • Select the VPCChanges metric.
  5. Click Select metric.

Step 4: Configure Alarm Conditions

  1. Under Specify metric and conditions:
    • Statistic: Sum
    • Period: 5 minutes (or your preferred window).
    • Threshold type: Static.
    • Whenever VPCChanges is: >= 1.
  2. Click Next.

Step 5: Configure Notification (SNS)

  1. Under Notification:
    • For Alarm state trigger: In alarm.
    • Select an SNS topic:
      • Choose an existing topic (e.g., security-alerts)
        or
      • Click Create new topic, name it (e.g., VPC-Changes-Topic), and enter one or more email addresses.
  2. Click Next.

Step 6: Name and Create the Alarm

  1. Alarm name: VPC-Changes-Alarm.
  2. Alarm description: Alerts when VPC configuration changes are detected via CloudTrail.
  3. Review the settings and click Create alarm.

Once this is in place, any matching VPC-related CloudTrail event will increment the VPCChanges metric and trigger the CloudWatch alarm, sending a notification via SNS.
Below is one way to remediate “VPC Changes Alarm Should Be Enabled” using AWS CLI by:
  1. ensuring CloudTrail is logging to CloudWatch Logs
  2. creating a metric filter for VPC changes
  3. creating a CloudWatch alarm on that metric.
Adjust names/regions as needed.

0. Prerequisites

  • You have a CloudTrail trail sending logs to a CloudWatch Logs log group (say /aws/cloudtrail/logs).
  • You know the region and account ID.
If you don’t yet send CloudTrail to CloudWatch Logs, create or update a trail first.

1. Confirm / Set CloudTrail → CloudWatch Logs

If you already have a trail with CloudWatchLogsLogGroupArn set, you can skip to step 2.Example: create a new trail that sends to /aws/cloudtrail/logs:
cloudtrail-cw-trust.json (example):
Attach a policy to allow writes to that log group:
cloudtrail-cw-policy.json (replace region/account/log-group if needed):
Now create the trail:
Enable logging:

2. Create a CloudWatch Logs Metric Filter for VPC Changes

Pick the relevant VPC events. Common ones include:
  • CreateVpc, DeleteVpc, ModifyVpcAttribute
  • CreateSubnet, DeleteSubnet, ModifySubnetAttribute
  • CreateRouteTable, DeleteRouteTable, AssociateRouteTable, DisassociateRouteTable, ReplaceRouteTableAssociation
  • CreateRoute, DeleteRoute, ReplaceRoute
  • CreateInternetGateway, DeleteInternetGateway, AttachInternetGateway, DetachInternetGateway
  • CreateNatGateway, DeleteNatGateway
  • CreateVpcPeeringConnection, DeleteVpcPeeringConnection, etc.
Sample filter pattern (you can extend):
This will increment the metric Security/VpcChanges by 1 every time a matching event appears.

3. Create an SNS Topic for Alarm Notifications

Get the ARN:
Subscribe an email (or other endpoint):
Confirm the subscription from your email.

4. Create the CloudWatch Alarm on the Metric

Example: alarm whenever at least 1 VPC change event occurs in a 5‑minute period.

5. Validate

  • Make a test VPC change (e.g., create or modify a subnet).
  • Confirm:
    • CloudTrail logs the event into the log group.
    • The metric Security/VpcChanges increments.
    • The VpcChangesDetected alarm goes into ALARM state.
    • An SNS notification is received.
These steps implement an AWS CloudWatch–based alarm that detects VPC configuration changes and satisfies the “VPC Changes Alarm Should Be Enabled” requirement via AWS CLI.
To remediate “VPC Changes Alarm Should Be Enabled” in AWS using Python, you typically need:
  1. A CloudTrail that logs management events.
  2. That CloudTrail delivering logs to a CloudWatch Logs log group.
  3. A CloudWatch Logs metric filter that detects VPC-change API calls.
  4. A CloudWatch alarm on that metric.
Below is a minimal, end‑to‑end example using boto3.

1. Prerequisites

  • Python 3.x
  • boto3 installed:
  • AWS credentials configured (via aws configure, environment variables, or instance profile).
  • An SNS topic ARN to receive the alarm notifications (or create one via console/CLI).
Assume:
  • Region: us-east-1
  • CloudTrail log group: /aws/cloudtrail/vpc-changes
  • Metric name: VPCChangeCount
  • Namespace: SecurityMonitoring
  • Alarm name: VPC_Changes_Alarm
  • SNS topic ARN: arn:aws:sns:us-east-1:123456789012:security-alerts

2. Ensure CloudTrail Is Sending to a CloudWatch Logs Log Group

If you already have an org/tenant-wide CloudTrail that sends management events to CloudWatch Logs, you can reuse that log group and skip creating a new trail. Otherwise:
If you already have a central CloudTrail and log group, just set logs_group_name to that existing log group and skip trail creation.

3. Create a Metric Filter for VPC Changes

The filter pattern will match CloudTrail events for VPC‑related API calls.Common VPC‑change events:
  • CreateVpc, DeleteVpc, ModifyVpcAttribute
  • CreateSubnet, DeleteSubnet, ModifySubnetAttribute
  • CreateRouteTable, DeleteRouteTable, AssociateRouteTable, DisassociateRouteTable, ReplaceRouteTableAssociation
  • CreateRoute, DeleteRoute, ReplaceRoute
  • CreateInternetGateway, AttachInternetGateway, DetachInternetGateway, DeleteInternetGateway
  • CreateNatGateway, DeleteNatGateway
  • CreateVpcPeeringConnection, DeleteVpcPeeringConnection, AcceptVpcPeeringConnection, RejectVpcPeeringConnection
  • CreateNetworkAcl, DeleteNetworkAcl, CreateNetworkAclEntry, DeleteNetworkAclEntry, ReplaceNetworkAclEntry
  • etc.
Example pattern (trim or extend as required):

4. Create the CloudWatch Alarm on the Metric

Trigger if at least 1 VPC change occurs in a 5‑minute period:

5. Quick Validation

  1. Make a small VPC change (e.g., create a test subnet).
  2. Wait a few minutes.
  3. Check:
    • CloudWatch Logs: confirm CloudTrail events are arriving.
    • CloudWatch Metrics → SecurityMonitoring/VPCChangeCount shows datapoints.
    • CloudWatch Alarms: VPC_Changes_Alarm moves to ALARM state and sends SNS notification.
This fully remediates the “VPC Changes Alarm Should Be Enabled” requirement using Python.
This remediation creates new resources (SNS topic, SNS email subscription, log metric filter, and CloudWatch alarm); existing resources are not replaced. You must replace YOUR_EMAIL_ADDRESS and CLOUDTRAIL_LOG_GROUP_NAME with your actual values and confirm the SNS email subscription manually from your inbox.To verify, terraform plan should show 4 resources to add (aws_sns_topic, aws_sns_topic_subscription, aws_cloudwatch_log_metric_filter, and aws_cloudwatch_metric_alarm) and no changes/destroys for existing resources.

Additional Reading: