Terraform-provider-newrelic: Perpetual drift in alert conditions with multiple entities

Created on 15 May 2019  路  3Comments  路  Source: newrelic/terraform-provider-newrelic

Terraform Version

Terraform v0.11.11

  • provider.newrelic v1.5.0

Affected Resource(s)

newrelic_alert_condition

Terraform Configuration Files

resource "newrelic_alert_condition" foo" {
  condition_scope = "application"

  entities = [
    "${data.newrelic_application.app1.id}",
    "${data.newrelic_application.app2.id}",
    "${data.newrelic_application.app3id}",
  ]

  # BUG? These seem to get re-ordered
  lifecycle {
    ignore_changes = ["entities"]
  }

  metric    = "apdex"
  name      = "Apdex (Low)"
  policy_id = "${data.terraform_remote_state.nr_monitoring.ops_policy_id}"

  term {
    duration      = 10
    operator      = "below"
    priority      = "critical"
    threshold     = "0.7"
    time_function = "all"
  }

  term {
    duration      = 30
    operator      = "below"
    priority      = "warning"
    threshold     = "0.85"
    time_function = "all"
  }

  type = "apm_app_metric"
}

Expected Behavior

The resource should get created successfully and subsequent applies should not show any drift.

Actual Behavior

Subsequent apply shows something like:

~ newrelic_alert_condition.error_percentage_slack
entities.0: "31315057" => "2206646"
entities.1: "2206646" => "90873514"
entities.2: "90873514" => "31315057"

Steps to Reproduce

  1. terraform apply
  2. terrafrom plan

Important Factoids

There's a work-around listed above in the code to ignore changes for the entities. This makes it difficult to modify the entities list though

Most helpful comment

Using a TypeSet vs. a TypeList for entities may fix this.

All 3 comments

Using a TypeSet vs. a TypeList for entities may fix this.

Hope to see this fix released soon.

Fix has been merged.

Was this page helpful?
0 / 5 - 0 ratings