diff --git a/sysdig/resource_sysdig_monitor_alert_v2_change_test.go b/sysdig/resource_sysdig_monitor_alert_v2_change_test.go index 140c5a6c..cac9f227 100644 --- a/sysdig/resource_sysdig_monitor_alert_v2_change_test.go +++ b/sysdig/resource_sysdig_monitor_alert_v2_change_test.go @@ -57,6 +57,18 @@ func TestAccAlertV2Change(t *testing.T) { { Config: alertV2ChangeWithUnreportedAlertNotificationsRetentionSec(rText()), }, + { + Config: alertV2ChangeWithNotEqualOperator(rText()), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("sysdig_monitor_alert_v2_change.sample", "operator", "!="), + ), + }, + { + Config: alertV2ChangeWithEqualOperator(rText()), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("sysdig_monitor_alert_v2_change.sample", "operator", "="), + ), + }, { Config: alertV2ChangeWithWarningThreshold(rText()), }, @@ -314,6 +326,36 @@ resource "sysdig_monitor_alert_v2_change" "sample" { `, name) } +func alertV2ChangeWithNotEqualOperator(name string) string { + return fmt.Sprintf(` +resource "sysdig_monitor_alert_v2_change" "sample" { + name = "TERRAFORM TEST - CHANGE %s" + metric = "sysdig_container_cpu_used_percent" + group_aggregation = "avg" + time_aggregation = "avg" + operator = "!=" + threshold = 50 + shorter_time_range_seconds = 300 + longer_time_range_seconds = 3600 +} +`, name) +} + +func alertV2ChangeWithEqualOperator(name string) string { + return fmt.Sprintf(` +resource "sysdig_monitor_alert_v2_change" "sample" { + name = "TERRAFORM TEST - CHANGE %s" + metric = "sysdig_container_cpu_used_percent" + group_aggregation = "avg" + time_aggregation = "avg" + operator = "=" + threshold = 50 + shorter_time_range_seconds = 300 + longer_time_range_seconds = 3600 +} +`, name) +} + func alertV2ChangeWithWarningThreshold(name string) string { return fmt.Sprintf(` resource "sysdig_monitor_notification_channel_email" "nc_email1" { diff --git a/sysdig/resource_sysdig_monitor_alert_v2_event_test.go b/sysdig/resource_sysdig_monitor_alert_v2_event_test.go index d68d5c85..40c4251e 100644 --- a/sysdig/resource_sysdig_monitor_alert_v2_event_test.go +++ b/sysdig/resource_sysdig_monitor_alert_v2_event_test.go @@ -36,6 +36,18 @@ func TestAccAlertV2Event(t *testing.T) { { Config: alertV2EventWithScrambledSources(rText()), }, + { + Config: alertV2EventWithNotEqualOperator(rText()), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("sysdig_monitor_alert_v2_event.sample", "operator", "!="), + ), + }, + { + Config: alertV2EventWithEqualOperator(rText()), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("sysdig_monitor_alert_v2_event.sample", "operator", "="), + ), + }, { Config: alertV2EventWithWarningThreshold(rText()), }, @@ -138,6 +150,50 @@ resource "sysdig_monitor_alert_v2_event" "sample" { `, name) } +func alertV2EventWithNotEqualOperator(name string) string { + return fmt.Sprintf(` +resource "sysdig_monitor_alert_v2_event" "sample" { + + name = "TERRAFORM TEST - EVENTV2 %s" + filter = "xxx" + operator = "!=" + threshold = 50 + + scope { + label = "kube_cluster_name" + operator = "in" + values = ["thom-cluster1", "demo-env-prom"] + } + + range_seconds = 600 + +} + +`, name) +} + +func alertV2EventWithEqualOperator(name string) string { + return fmt.Sprintf(` +resource "sysdig_monitor_alert_v2_event" "sample" { + + name = "TERRAFORM TEST - EVENTV2 %s" + filter = "xxx" + operator = "=" + threshold = 50 + + scope { + label = "kube_cluster_name" + operator = "in" + values = ["thom-cluster1", "demo-env-prom"] + } + + range_seconds = 600 + +} + +`, name) +} + func alertV2EventWithWarningThreshold(name string) string { return fmt.Sprintf(` resource "sysdig_monitor_alert_v2_event" "sample" { diff --git a/sysdig/resource_sysdig_monitor_alert_v2_metric_test.go b/sysdig/resource_sysdig_monitor_alert_v2_metric_test.go index 4b15482c..575b0d23 100644 --- a/sysdig/resource_sysdig_monitor_alert_v2_metric_test.go +++ b/sysdig/resource_sysdig_monitor_alert_v2_metric_test.go @@ -84,6 +84,18 @@ func TestAccAlertV2Metric(t *testing.T) { { Config: alertV2MetricWithLabels(rText()), }, + { + Config: alertV2MetricWithNotEqualOperator(rText()), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("sysdig_monitor_alert_v2_metric.sample", "operator", "!="), + ), + }, + { + Config: alertV2MetricWithEqualOperator(rText()), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("sysdig_monitor_alert_v2_metric.sample", "operator", "="), + ), + }, { Config: alertV2MetricWithWarningThreshold(rText()), }, @@ -530,6 +542,38 @@ resource "sysdig_monitor_alert_v2_metric" "sample" { `, name) } +func alertV2MetricWithNotEqualOperator(name string) string { + return fmt.Sprintf(` +resource "sysdig_monitor_alert_v2_metric" "sample" { + + name = "TERRAFORM TEST - METRICV2 %s" + metric = "sysdig_container_cpu_used_percent" + group_aggregation = "avg" + time_aggregation = "avg" + operator = "!=" + threshold = 50 + range_seconds = 600 + +} +`, name) +} + +func alertV2MetricWithEqualOperator(name string) string { + return fmt.Sprintf(` +resource "sysdig_monitor_alert_v2_metric" "sample" { + + name = "TERRAFORM TEST - METRICV2 %s" + metric = "sysdig_container_cpu_used_percent" + group_aggregation = "avg" + time_aggregation = "avg" + operator = "=" + threshold = 50 + range_seconds = 600 + +} +`, name) +} + func alertV2MetricWithWarningThreshold(name string) string { return fmt.Sprintf(` resource "sysdig_monitor_notification_channel_email" "nc_email1" {