diff --git a/CHANGELOG.md b/CHANGELOG.md index 25fec583..4e243b8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.28.0 (Unreleased) +FEATURES: +* resource/sumologic_monitor: Added support for setting `time_zone` at Monitor level for notifications content (GH-586) + ## 2.27.1 (November 14, 2023) BUG FIXES: * Fixes `resource_sumologic_cse_match_list` constant change when defining a match list containing a custom column using the custom columns name instead of ID (GH-591) diff --git a/sumologic/resource_sumologic_monitors_library_monitor.go b/sumologic/resource_sumologic_monitors_library_monitor.go index 5ae9b73a..2da20f49 100644 --- a/sumologic/resource_sumologic_monitors_library_monitor.go +++ b/sumologic/resource_sumologic_monitors_library_monitor.go @@ -65,6 +65,11 @@ func getMonitorBaseSchema() map[string]*schema.Schema { DiffSuppressFunc: SuppressEquivalentTimeDiff(false), }, + "time_zone": { + Type: schema.TypeString, + Optional: true, + }, + "alert_name": { Type: schema.TypeString, Optional: true, @@ -813,6 +818,7 @@ func resourceSumologicMonitorsLibraryMonitorRead(d *schema.ResourceData, meta in d.Set("slo_id", monitor.SloID) d.Set("notification_group_fields", monitor.NotificationGroupFields) d.Set("tags", monitor.Tags) + d.Set("time_zone", monitor.TimeZone) // set notifications notifications := make([]interface{}, len(monitor.Notifications)) @@ -1564,6 +1570,7 @@ func resourceToMonitorsLibraryMonitor(d *schema.ResourceData) MonitorsLibraryMon ModifiedBy: d.Get("modified_by").(string), IsMutable: d.Get("is_mutable").(bool), Version: d.Get("version").(int), + TimeZone: d.Get("time_zone").(string), Notifications: notifications, Type: d.Get("type").(string), ParentID: d.Get("parent_id").(string), diff --git a/sumologic/resource_sumologic_monitors_library_monitor_test.go b/sumologic/resource_sumologic_monitors_library_monitor_test.go index 2502207c..b7f2da87 100644 --- a/sumologic/resource_sumologic_monitors_library_monitor_test.go +++ b/sumologic/resource_sumologic_monitors_library_monitor_test.go @@ -203,6 +203,7 @@ func TestAccSumologicMonitorsLibraryMonitor_create(t *testing.T) { testMonitorType := "Logs" testIsDisabled := false canonicalTestEvaluationDelay := "1h" + testTimeZone := "America/New_York" testQueries := []MonitorQuery{ { RowID: "A", @@ -272,6 +273,7 @@ func TestAccSumologicMonitorsLibraryMonitor_create(t *testing.T) { resource.TestCheckResourceAttr("sumologic_monitor.test", "type", testType), resource.TestCheckResourceAttr("sumologic_monitor.test", "description", testDescription), resource.TestCheckResourceAttr("sumologic_monitor.test", "evaluation_delay", canonicalTestEvaluationDelay), + resource.TestCheckResourceAttr("sumologic_monitor.test", "time_zone", testTimeZone), resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testContentType), resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testQueries[0].RowID), resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testTriggers[0].TriggerType), @@ -372,6 +374,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) { testPlaybook := "This is a test playbook" testIsDisabled := false canonicalTestEvaluationDelay := "1h" + testTimeZone := "America/New_York" testQueries := []MonitorQuery{ { RowID: "A", @@ -434,6 +437,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) { testUpdatedPlaybook := "This is an updated test playbook" testUpdatedIsDisabled := true testUpdatedEvaluationDelay := "8m" + testUpdatedTimeZone := "America/Chicago" testUpdatedQueries := []MonitorQuery{ { RowID: "A", @@ -503,6 +507,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) { resource.TestCheckResourceAttr("sumologic_monitor.test", "type", testType), resource.TestCheckResourceAttr("sumologic_monitor.test", "description", testDescription), resource.TestCheckResourceAttr("sumologic_monitor.test", "evaluation_delay", canonicalTestEvaluationDelay), + resource.TestCheckResourceAttr("sumologic_monitor.test", "time_zone", testTimeZone), resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testContentType), resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testQueries[0].RowID), resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testTriggers[0].TriggerType), @@ -527,6 +532,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) { resource.TestCheckResourceAttr("sumologic_monitor.test", "type", testUpdatedType), resource.TestCheckResourceAttr("sumologic_monitor.test", "description", testUpdatedDescription), resource.TestCheckResourceAttr("sumologic_monitor.test", "evaluation_delay", testUpdatedEvaluationDelay), + resource.TestCheckResourceAttr("sumologic_monitor.test", "time_zone", testUpdatedTimeZone), resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testUpdatedContentType), resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testUpdatedQueries[0].RowID), resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testUpdatedTriggers[0].TriggerType), @@ -802,6 +808,7 @@ resource "sumologic_monitor" "test" { content_type = "Monitor" monitor_type = "Logs" evaluation_delay = "60m" + time_zone = "America/New_York" queries { row_id = "A" query = "_sourceCategory=monitor-manager error" @@ -929,6 +936,7 @@ resource "sumologic_monitor" "test" { content_type = "Monitor" monitor_type = "Logs" evaluation_delay = "8m" + time_zone = "America/Chicago" queries { row_id = "A" query = "_sourceCategory=monitor-manager info" @@ -1011,6 +1019,7 @@ resource "sumologic_monitor" "test_monitor_connection" { content_type = "Monitor" monitor_type = "Logs" evaluation_delay = "8m" + time_zone = "Asia/Kolkata" queries { row_id = "A" query = "_sourceCategory=monitor-manager info" @@ -1286,6 +1295,7 @@ resource "sumologic_monitor" "test" { is_disabled = false content_type = "Monitor" monitor_type = "Slo" + time_zone = "America/New_York" slo_id = sumologic_slo.slo_tf_window_metric_ratio.id trigger_conditions { %s diff --git a/sumologic/sumologic_monitors_library_monitor.go b/sumologic/sumologic_monitors_library_monitor.go index 7fbd2c38..3b4a51b3 100644 --- a/sumologic/sumologic_monitors_library_monitor.go +++ b/sumologic/sumologic_monitors_library_monitor.go @@ -150,6 +150,7 @@ type MonitorsLibraryMonitor struct { SloID string `json:"sloId,omitempty"` NotificationGroupFields []string `json:"notificationGroupFields,omitempty"` Tags map[string]interface{} `json:"tags"` + TimeZone string `json:"timeZone,omitempty"` } type MonitorQuery struct {