Project: KICS (Provisioning / Security & Compliance)
File: 0a8e8dc5-b6fc-44fc-b5a1-969ec950f9b0.md

title: CloudWatch Changes To NACL Alarm Missing hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 0a8e8dc5-b6fc-44fc-b5a1-969ec950f9b0 Query name: CloudWatch Changes To NACL Alarm Missing Platform: Terraform Severity: <span style="color:#ff7213">Medium</span> Category: Observability URL: Ensure a log metric filter and alarm exist for changes to NACL<br> ```tf title="Positive test num. 1 - tf file" hl_lines="1" provider "aws" { region = "us-east-2" } resource "awscloudwatchloggroup" "CISCloudWatch_LogsGroup" { name = "CISCloudWatchLogsGroup" } resource "awssnstopic" "cisalertssns_topic" { name = "cis-alerts-sns-topic" } resource "awscloudwatchmetricalarm" "cischanges_nacl" { alarm_name = "CIS-4.11-Changes-NACL" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metric_name = "OTHER FILTER" namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarmactions = [awssnstopic.cisalertssnstopic.arn] insufficientdataactions = [] } resource "awscloudwatchlogmetricfilter" "cischangesnacl" { name = "CIS-4.11-Changes-NACL" pattern = "{ ($.eventName = CreateNetworkAcl) || ($.eventName = CreateNetworkAclEntry) || ($.eventName = DeleteNetworkAcl) || ($.eventName = DeleteNetworkAclEntry) || ($.eventName = ReplaceNetworkAclEntry) || ($.eventName = ReplaceNetworkAclAssociation) }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-4.11-Changes-NACL" namespace = "CISMetricAlarm_Namespace" value = "1" } } ``` ```tf title="Positive test num. 2 - tf file" hl_lines="1" provider "aws" { region = "us-east-2" } resource "awscloudwatchloggroup" "CISCloudWatch_LogsGroup" { name = "CISCloudWatchLogsGroup" } resource "awssnstopic" "cisalertssns_topic" { name = "cis-alerts-sns-topic" } resource "awscloudwatchmetricalarm" "cischanges_nacl" { alarm_name = "CIS-4.11-Changes-NACL" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.cischanges_nacl.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarmactions = [awssnstopic.cisalertssnstopic.arn] insufficientdataactions = [] } resource "awscloudwatchlogmetricfilter" "cischangesnacl" { name = "CIS-4.11-Changes-NACL" pattern = "{ ($.eventName = CreateNetworkAclEntry) || ($.eventName = DeleteNetworkAcl) || ($.eventName = DeleteNetworkAclEntry) || ($.eventName = ReplaceNetworkAclEntry) || ($.eventName = ReplaceNetworkAclAssociation) }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-4.11-Changes-NACL" namespace = "CISMetricAlarm_Namespace" value = "1" } } ``` ```tf title="Negative test num. 1 - tf file" provider "aws" { region = "us-east-2" } resource "awscloudwatchloggroup" "CISCloudWatch_LogsGroup" { name = "CISCloudWatchLogsGroup" } resource "awssnstopic" "cisalertssns_topic" { name = "cis-alerts-sns-topic" } resource "awscloudwatchmetricalarm" "cischanges_nacl" { alarm_name = "CIS-4.11-Changes-NACL" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.cischanges_nacl.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarmactions = [awssnstopic.cisalertssnstopic.arn] insufficientdataactions = [] } resource "awscloudwatchlogmetricfilter" "cischangesnacl" { name = "CIS-4.11-Changes-NACL" pattern = "{ ($.eventName = CreateNetworkAcl) || ($.eventName = CreateNetworkAclEntry) || ($.eventName = DeleteNetworkAcl) || ($.eventName = DeleteNetworkAclEntry) || ($.eventName = ReplaceNetworkAclEntry) || ($.eventName = ReplaceNetworkAclAssociation) }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-4.11-Changes-NACL" namespace = "CISMetricAlarm_Namespace" value = "1" } } ```