diff --git a/datadog/resource_datadog_monitor.go b/datadog/resource_datadog_monitor.go index dd83a67c9..38f92e9de 100644 --- a/datadog/resource_datadog_monitor.go +++ b/datadog/resource_datadog_monitor.go @@ -380,13 +380,16 @@ func resourceDatadogMonitorRead(d *schema.ResourceData, meta interface{}) error d.Set("message", m.GetMessage()) d.Set("query", m.GetQuery()) if typ, ok := m.GetTypeOk(); ok { - if d.Get("type").(string) == "metric alert" && typ == "query alert" { + if d.Get("type").(string) == "metric alert" && typ == "query alert" || + d.Get("type").(string) == "query alert" && typ == "metric alert" { /* Datadog API quirk, see https://github.com/hashicorp/terraform/issues/13784 - * + * and https://github.com/terraform-providers/terraform-provider-datadog/issues/241 * If current type of monitor is "metric alert" and the API is returning "query alert", * we want to keep "metric alert". We previously had this as DiffSuppressFunc on "type". * After adding a call to "resourceDatadogMonitorRead" in create/update methods, this - * started creating the monitor as "query alert". To make sure that the behaviour stays + * started creating the monitor as "query alert". The same applies for the reverse, when the + * current type of monitor is "query alert" and the API is returning "metric alert" + * To make sure that the behaviour stays * the same, we added this code (which made DiffSuppressFunc useless, so we removed it). */ } else {