Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic blocks do not fix the order in which listings are processed #1720

Closed
melumuccu opened this issue Mar 22, 2022 · 4 comments · May be fixed by #2531
Closed

Dynamic blocks do not fix the order in which listings are processed #1720

melumuccu opened this issue Mar 22, 2022 · 4 comments · May be fixed by #2531

Comments

@melumuccu
Copy link

melumuccu commented Mar 22, 2022

Terraform Version

# tf -v
Terraform v1.1.7
on linux_amd64
+ provider registry.terraform.io/newrelic/newrelic v2.39.2

# tf providers

Providers required by configuration:
.
├── provider[registry.terraform.io/newrelic/newrelic] 2.39.2
├── module.base
│   └── provider[registry.terraform.io/newrelic/newrelic]
├── module.future
│   └── provider[registry.terraform.io/newrelic/newrelic]
├── module.nrql
│   └── provider[registry.terraform.io/newrelic/newrelic]
├── module.past
│   └── provider[registry.terraform.io/newrelic/newrelic]
├── module.synthetics_monitor
│   └── provider[registry.terraform.io/newrelic/newrelic]
├── module.time_unit
│   └── provider[registry.terraform.io/newrelic/newrelic]
└── module.urls
    └── provider[registry.terraform.io/newrelic/newrelic]

Providers required by state:

    provider[registry.terraform.io/newrelic/newrelic]

Affected Resource(s)

  • newrelic_one_dashboard

Terraform Configuration

  • main.tf
terraform {
  required_version = "~> 1.0"
  required_providers {
    newrelic = {
      version = "2.39.2"
      source = "newrelic/newrelic"
    }
  }
}

provider "newrelic" {}
  • test.tf
//-------------------------------------
// resource
//-------------------------------------
resource "newrelic_one_dashboard" "test_lighthouse" {
  name = "(test)Lighthouse_goonet-prod"
  page {
    name = "lighthouse"
    dynamic "widget_line" {
      for_each = local.test_targets
      iterator = target
      content {
        title  = module.urls.urls["${target.value}"].url_name
        row    = target.key + 1
        column = 1     
        nrql_query {
          query = <<EOF
${module.nrql.nrql["lighthouse_dashboard"].nrql1}  average(custom.performanceScore) AS 'desktop'
${module.nrql.nrql["lighthouse_dashboard"].nrql2}  monitorName = '(test)LIGHTHOUSE - ${target.key} - desktop'
${module.nrql.nrql["lighthouse_dashboard"].nrql3}
          EOF
        }
      }
    }
  }
}
//-------------------------------------
// locals
//-------------------------------------
locals {
  test_targets = [
    "https://www.goo-net.com/",
    "https://www.goo-net.com/catalog/TOYOTA/",
    "https://www.goo-net.com/catalog/TOYOTA/ALPHARD/",
    "https://www.goo-net.com/magazine/",
  ]
}

Actual Behavior

After "apply", "change" was detected when "plan" was performed without modifying any source code.

Expected Behavior

No "change" was detected

Steps to Reproduce

  1. $ terraform apply
  2. $ terraform plan

logs
https://gist.github.com/melumuccu/2d9254ff3cf3d0135fef2b30cc6c4ac0

@shiva-bandari
Copy link
Contributor

Hi @melumuccu,

Thank you for reporting this issue.

While reviewing the script we are suspecting that some changes were made outside of the terraform,
for example :
a. Column value changes from 1 to 5.
b. Condition changes in NRQL query.

Could you provide the following additional information to troubleshoot further on this issue.

  1. Import the dashboard to JSON format. Please refer to the link: https://docs.newrelic.com/docs/query-your-data/explore-
    query-data/dashboards/dashboards-charts-import-export-data/#dashboards
  2. Also provide the dashboard screenshots (if possible before and after changes) to the email: [email protected]

@melumuccu
Copy link
Author

melumuccu commented Mar 23, 2022

Thanks for the reply.

While reviewing the script we are suspecting that some changes were made outside of the terraform,
for example :
a. Column value changes from 1 to 5.
b. Condition changes in NRQL query.

Upon additional investigation, it appears that the order in which the arrays are processed in "for_each" in the dynamic block is undefined.

Please see documents that follow.
The dashboard does not seem to change before or after "apply".

Sorry, The exact same dashboard had already been deleted, so I am attaching another dashboard with similar symptoms.

  1. Import the dashboard to JSON format.

before "apply": https://gist.github.com/melumuccu/8f2e59b415753f5bb46e575827fb6ce7
after "apply": https://gist.github.com/melumuccu/8f786d02bc95b4efe6f06561df51095f

I tried to get a before and after, but there is no difference...

  1. Also provide the dashboard screenshots (if possible before and after changes) to the email

I sent you an email. The title is this issue one.

@shiva-bandari
Copy link
Contributor

Hi @melumuccu
This is a duplicate of the issue: #1452.
There is nothing we can do now, however we'll keep this in mind when redesigning the dashboard resource.

@melumuccu
Copy link
Author

melumuccu commented Mar 25, 2022

@shiva-bandari
OK, Thanks.
For now, I use "ignore_changes" in "lifecycle".
https://www.terraform.io/language/meta-arguments/lifecycle#ignore_changes

This is the only thing I can come up with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants