Project: KICS (Provisioning / Security & Compliance)
File: 9d0d4512-1959-43a2-a17f-72360ff06d1b.md

title: CloudWatch VPC Changes Alarm Missing hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 9d0d4512-1959-43a2-a17f-72360ff06d1b Query name: CloudWatch VPC Changes Alarm Missing Platform: Terraform Severity: <span style="color:#ff7213">Medium</span> Category: Observability URL: Ensure a log metric filter and alarm exist for VPC changes<br> ```tf title="Positive test num. 1 - tf file" hl_lines="1" resource "awscloudwatchlogmetricfilter" "CISVPCChangesMetricFilter" { name = "CIS-VPCChanges" pattern = "{ ($.eventName = CreateVpc) || ($.eventName = DeleteVpc) || ($.eventName = ModifyVpcAttribute) || ($.eventName = AcceptVpcPeeringConnection) || ($.eventName = CreateVpcPeeringConnection) || ($.eventName = DeleteVpcPeeringConnection) || ($.eventName = RejectVpcPeeringConnection) || ($.eventName = AttachClassicLinkVpc) || ($.eventName = DetachClassicLinkVpc) || ($.eventName = DisableVpcClassicLink) || ($.eventName = EnableVpcClassicLink) }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-VPCChanges" namespace = "CISMetricAlarm_Namespace" value = "1" } } resource "awscloudwatchmetricalarm" "CISVPCChangesCW_Alarm" { alarm_name = "CIS-3.14-VPCChanges" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metric_name = "XXXX NOT YOUR FILTER XXXX" namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarm_description = "Monitoring changes to VPC will help ensure that all VPC traffic flows through an expected path." alarmactions = [awssnstopic.CISAlertsSNSTopic.arn] insufficientdataactions = [] } ``` ```tf title="Positive test num. 2 - tf file" hl_lines="1" resource "awscloudwatchlogmetricfilter" "cisnomfaconsolesigninmetricfilter" { name = "CIS-ConsoleSigninWithoutMFA" pattern = "{ ($.eventName = \"ConsoleLogin\") && ($.additionalEventData.MFAUsed != \"Yes\") }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-ConsoleSigninWithoutMFA" namespace = "CISMetricAlarm_Namespace" value = "1" } } resource "awscloudwatchmetricalarm" "cisnomfaconsolesignincw_alarm" { alarm_name = "CIS-3.2-ConsoleSigninWithoutMFA" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.cisnomfaconsolesigninmetric_filter.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarm_description = "Monitoring for single-factor console logins will increase visibility into accounts that are not protected by MFA." alarmactions = [awssnstopic.CISAlertsSNSTopic.arn] insufficientdataactions = [] } ``` ```tf title="Positive test num. 3 - tf file" hl_lines="1" resource "awscloudwatchlogmetricfilter" "CISVPCChangesMetricFilter" { name = "CIS-VPCChanges" pattern = "{ ($.eventName = CreateVpc) || ($.eventName = ModifyVpcAttribute) || ($.eventName = AcceptVpcPeeringConnection) || ($.eventName = CreateVpcPeeringConnection) || ($.eventName = DeleteVpcPeeringConnection) || ($.eventName = RejectVpcPeeringConnection) || ($.eventName = AttachClassicLinkVpc) || ($.eventName = DetachClassicLinkVpc) || ($.eventName = EnableVpcClassicLink) }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-VPCChanges" namespace = "CISMetricAlarm_Namespace" value = "1" } } resource "awscloudwatchmetricalarm" "CISVPCChangesCW_Alarm" { alarm_name = "CIS-3.14-VPCChanges" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.CISVPCChangesMetric_Filter.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarm_description = "Monitoring changes to VPC will help ensure that all VPC traffic flows through an expected path." alarmactions = [awssnstopic.CISAlertsSNSTopic.arn] insufficientdataactions = [] } ``` ```tf title="Negative test num. 1 - tf file" resource "awscloudwatchlogmetricfilter" "CISVPCChangesMetricFilter" { name = "CIS-VPCChanges" pattern = "{ ($.eventName = CreateVpc) || ($.eventName = DeleteVpc) || ($.eventName = ModifyVpcAttribute) || ($.eventName = AcceptVpcPeeringConnection) || ($.eventName = CreateVpcPeeringConnection) || ($.eventName = DeleteVpcPeeringConnection) || ($.eventName = RejectVpcPeeringConnection) || ($.eventName = AttachClassicLinkVpc) || ($.eventName = DetachClassicLinkVpc) || ($.eventName = DisableVpcClassicLink) || ($.eventName = EnableVpcClassicLink) }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-VPCChanges" namespace = "CISMetricAlarm_Namespace" value = "1" } } resource "awscloudwatchmetricalarm" "CISVPCChangesCW_Alarm" { alarm_name = "CIS-3.14-VPCChanges" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.CISVPCChangesMetric_Filter.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarm_description = "Monitoring changes to VPC will help ensure that all VPC traffic flows through an expected path." alarmactions = [awssnstopic.CISAlertsSNSTopic.arn] insufficientdataactions = [] } ```