terraform-provider-sumologic icon indicating copy to clipboard operation
terraform-provider-sumologic copied to clipboard

Trigger conditions/resolution/occurence_type not updated correctly in terraform plan

Open MZochowskiSUMO opened this issue 2 years ago • 1 comments

Steps to reproduce

  1. Define new sumologic_monitor with metrics_static_condition as trigger_conditions. Inside resolution object do NOT specify occurence_type. E.g.:
resource "sumologic_monitor" "tf_test_to_be_removed" {
  name         = "Test"
  description  = "Test"
  type         = "MonitorsLibraryMonitor"
  is_disabled  = false
  content_type = "Monitor"
  monitor_type = "Metrics"
  evaluation_delay = "1m"

  queries {
    row_id = "A"
    query  = "metric=CPU* _sourceCategory=event-action"
  }

  trigger_conditions {
    metrics_static_condition {
      warning {
        time_range = "15m"
        occurrence_type = "Always"
        alert {
          threshold      = 40.0
          threshold_type = "GreaterThan"
        }
        resolution {
          threshold      = 40.0
          threshold_type = "LessThanOrEqual"
        }
      }
    }
  }
}
  1. terraform apply
  2. Add to resolution object `occurrence_type= "AtLeastOnce"
  3. terraform apply

Observed

terraform plan outputs the addition of occurrence_type again. It won't change after subsequent applies either. However, the value was updated in the backend.

Expected

terraform plan should output 0 changes after the second apply.

Code pointers

It appears that here we leave out some case during reading monitor from JSON: https://github.com/SumoLogic/terraform-provider-sumologic/blob/34d00d8271b04c32f9dd8c801ebb0914ac3768b5/sumologic/resource_sumologic_monitors_library_monitor.go#L1152

MZochowskiSUMO avatar Sep 27 '22 11:09 MZochowskiSUMO

Internal JIRA SUMO-202978

dlinsumo avatar Sep 27 '22 18:09 dlinsumo