Project: KICS (Provisioning / Security & Compliance)
File: 56a585f5-555c-48b2-8395-e64e4740a9cf.md

title: CloudWatch Disabling Or Scheduled Deletion Of Customer Created CMK Alarm Missing hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 56a585f5-555c-48b2-8395-e64e4740a9cf Query name: CloudWatch Disabling Or Scheduled Deletion Of Customer Created CMK Alarm Missing Platform: Terraform Severity: <span style="color:#ff7213">Medium</span> Category: Observability URL: Ensure a log metric filter and alarm exist for disabling or scheduled deletion of customer created CMK<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" "cisdisabledeletecmk" { alarm_name = "CIS-4.7-Disable-Scheduled-Delete-CMK" 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" "cisdisabledelete_cmk" { name = "CIS-4.7-Disable-Scheduled-Delete-CMK" pattern = "{ ($.eventSource = \"kms.amazonaws.com\") && (($.eventName = DisableKey) || ($.eventName = ScheduleKeyDeletion)) }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-4.7-Disable-Scheduled-Delete-CMK" 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" "cisdisabledeletecmk" { alarm_name = "CIS-4.7-Disable-Scheduled-Delete-CMK" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.cisdisabledeletecmk.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarmactions = [awssnstopic.cisalertssnstopic.arn] insufficientdataactions = [] } resource "awscloudwatchlogmetricfilter" "cisdisabledelete_cmk" { name = "CIS-4.7-Disable-Scheduled-Delete-CMK" pattern = "{ ($.eventSource = \"kms.amazonaws.com\") || (($.eventName = DisableKey) || ($.eventName = ScheduleKeyDeletion)) }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-4.7-Disable-Scheduled-Delete-CMK" namespace = "CISMetricAlarm_Namespace" value = "1" } } ``` ```tf title="Positive test num. 3 - 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" "cisdisabledeletecmk" { alarm_name = "CIS-4.7-Disable-Scheduled-Delete-CMK" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.cisdisabledeletecmk.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarmactions = [awssnstopic.cisalertssnstopic.arn] insufficientdataactions = [] } resource "awscloudwatchlogmetricfilter" "cisdisabledelete_cmk" { name = "CIS-4.7-Disable-Scheduled-Delete-CMK" pattern = "{ ($.eventSource = \"kms.amazonaws.com\") && (($.eventName = ScheduleKeyDeletion)) }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-4.7-Disable-Scheduled-Delete-CMK" 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" "cisdisabledeletecmk" { alarm_name = "CIS-4.7-Disable-Scheduled-Delete-CMK" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = "1" metricname = awscloudwatchlogmetricfilter.cisdisabledeletecmk.id namespace = "CISMetricAlarm_Namespace" period = "300" statistic = "Sum" threshold = "1" alarmactions = [awssnstopic.cisalertssnstopic.arn] insufficientdataactions = [] } resource "awscloudwatchlogmetricfilter" "cisdisabledelete_cmk" { name = "CIS-4.7-Disable-Scheduled-Delete-CMK" pattern = "{ ($.eventSource = \"kms.amazonaws.com\") && (($.eventName = DisableKey) || ($.eventName = ScheduleKeyDeletion)) }" loggroupname = awscloudwatchloggroup.CISCloudWatch_LogsGroup.name metric_transformation { name = "CIS-4.7-Disable-Scheduled-Delete-CMK" namespace = "CISMetricAlarm_Namespace" value = "1" } } ```