terraform-provider-newrelic: filter_current_dashboard of newrelic_one_dashboard is not handled properly

Please include the following with your bug report

Terraform Version

1.0.9

Affected Resource(s)

Please list the resources as a list, for example:

  • newrelic_one_dashboard
  • one_dashboard_raw (according to #1413 )

Terraform Configuration

Any basic config of newrelic_one_dashboard with widget_table and filter_current_dashboard=true

Actual Behavior

Terraform plan and apply operations show changes every time:

      ~ page {
...
          ~ widget_table {
              ~ filter_current_dashboard = false -> true

Expected Behavior

no changes

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply or terraform plan (after apply)

Debug Output

Panic Output

Important Factoids

References

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 10
  • Comments: 33 (12 by maintainers)

Most upvoted comments

I agree with @zeffron @mbazhlekova this has fixed it for me and I have not found any edge cases. Thank you for fixing this!

The experience I have is the same as what is reported:

Actual Behavior
Terraform plan and apply operations show changes every time:

      ~ page {
...
          ~ widget_table {
              ~ filter_current_dashboard = false -> true

Even though the state of the dashboard is unchanged, and terraform applied successfully, subsequent back-to-back TF runs express that the value needs to change from false to true (but never do). Thus, the feature does not work; “filter_current_dashboard of newrelic_one_dashboard is not handled properly”.

v2.41.0-beta.2 does seem to have resolved the issue for me.

Support for Lifecycle only exists on Resources, not Dynamic blocks. As the nature of a Dashboard can be complex at times and most have multiple pages and widgets, Dynamics are generally used.

https://github.com/hashicorp/terraform/issues/24188

I agree this helps the example, but for us it is not going to help in production.

Thanks @rdhar , I’ve added one_dashboard_raw to the affected resources list with a hope that all of them could be fixed at once.

@MrColeC @zeffron We rolled out another release - v2.41.0-beta.2 with a fix for the linked_entity_guids error. Please let us know if this resolves the issues you’re seeing.

Can confirm the beta seems to work for our use case as well.

While re-trying #1413, I came across a li’l tidbit that might help address this issue (i.e., unnecessary noise in the execution logs) with an interim solution: leveraging ignore_changes from Terraform’s lifecycle meta-argument docs.

resource "newrelic_one_dashboard" "the_dashboard" {
  lifecycle {
    ignore_changes = [
      page[0].widget_bar["filter_current_dashboard"],
      page[0].widget_pie["filter_current_dashboard"],
      page[0].widget_table["filter_current_dashboard"],
    ]
  }
  name = "The Dashboard"
  …

This will suppress redundant noise from filter_current_dashboard on subsequent updates. Almost goes without saying, the ideal solution here would still be for the provider to properly register the value of the boolean, but this isn’t too shabby a workaround.

Issue

Hi, this is still not working correctly in 2.34.1.

$ terraform -version
Terraform v1.1.2
on darwin_amd64
+ provider registry.terraform.io/newrelic/newrelic v2.34.1

I had some issue setting up dashboards originated from a json file copy from an old dashboard. The original dashboard had linked_entity_guids = [] to the old dashboard.

widget_bar {
  # omitting details
  linked_entity_guids = ["old-dashboard-guid"]
}

This works fine, however, it is pointing to the old dashboard.

So, I’ve changed the config to

widget_bar {
  # omitting details
  filter_current_dashboard = true
}

The dashboard still points to the old one.

Experiments

I did some experiments

  1. I created a dashboard like my real dashboard (business details omitted). Then both work fine. Widget 1 can filter the test dashboard.
resource "newrelic_one_dashboard" "test-dashboard" {

  page {
    widget_bar {
      name = "widget 1"
      filter_current_dashboard =  true
    }

    widget_bar {
       name = "widget 2"
      linked_entity_guids = ["old-dashboard-guid"]
    }
  }
}
  1. I removed the guids from widget 2. Then Widget 2 had no filters. This is also fine.
resource "newrelic_one_dashboard" "test-dashboard" {

  page {
    widget_bar {
      name = "widget 1"
      filter_current_dashboard =  true
    }

    widget_bar {
       name = "widget 2"
      linked_entity_guids = []
    }
  }
}
  1. I add filter_current_dashbaord = true to widget 2. However no filter is generated.
resource "newrelic_one_dashboard" "test-dashboard" {

  page {
    widget_bar {
      name = "widget 1"
      filter_current_dashboard =  true
    }

    widget_bar {
       name = "widget 2"
      filter_current_dashboard =  true
    }
  }
}

Screen Shot 2022-01-05 at 11 26 26