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

template_preset_variable diff not order-independent #2596

Open
joelmarty opened this issue Sep 30, 2024 · 0 comments
Open

template_preset_variable diff not order-independent #2596

joelmarty opened this issue Sep 30, 2024 · 0 comments
Labels

Comments

@joelmarty
Copy link

Datadog Terraform Provider Version

3.44.1

Terraform Version

1.9.6

What resources or data sources are affected?

datadog_dashboard

Terraform Configuration Files

resource "datadog_dashboard" "test" {
  title = "test dashboard"

  layout_type = "ordered"
  reflow_type = "fixed"

  template_variable {
    name = "env"
    defaults = ["dev"]
    available_values = ["dev", "stage", "prod"]
  }

  template_variable {
    name = "realm"
    defaults = ["us1"]
    available_values = ["us1", "us2", "eu1"]
  }

  template_variable_preset {
    name = "dev-us1"
    template_variable {
      name = "env"
      values = ["dev"]
    }
    template_variable {
      name = "realm"
      values = ["us1"]
    }
  }

  template_variable_preset {
    name = "dev-us2"
    template_variable {
      name = "env"
      values = ["dev"]
    }
    template_variable {
      name = "realm"
      values = ["us2"]
    }
  }

  widget {
    note_definition {
      content = "This is a test"
    }
    widget_layout {
      height = 2
      width  = 12
      x      = 0
      y      = 0
    }
  }
}

Relevant debug or panic output

n/a

Expected Behavior

Adding a template variable preset before dev-us1 should detect the addition of a new preset

Actual Behavior

Adding a template variable preset before dev-us1 shows the diff as a modification of all presets:

  # datadog_dashboard.test will be updated in-place
  ~ resource "datadog_dashboard" "test" {
        id                      = "mt9-5tu-2nz"
        tags                    = []
        # (9 unchanged attributes hidden)

      ~ template_variable_preset {
          ~ name = "dev-us1" -> "dev-eu1"

          ~ template_variable {
                name   = "realm"
              ~ values = [
                  ~ "us1" -> "eu1",
                ]
                # (1 unchanged attribute hidden)
            }

            # (1 unchanged block hidden)
        }
      ~ template_variable_preset {
          ~ name = "dev-us2" -> "dev-us1"

          ~ template_variable {
                name   = "realm"
              ~ values = [
                  ~ "us2" -> "us1",
                ]
                # (1 unchanged attribute hidden)
            }

            # (1 unchanged block hidden)
        }
      + template_variable_preset {
          + name = "dev-us2"

          + template_variable {
              + name   = "env"
              + values = [
                  + "dev",
                ]
            }
          + template_variable {
              + name   = "realm"
              + values = [
                  + "us2",
                ]
            }
        }

        # (3 unchanged blocks hidden)
    }

Steps to Reproduce

  1. terraform apply
  2. Add the following preset on first position:
  template_variable_preset {
    name = "dev-eu1"
    template_variable {
      name = "env"
      values = ["dev"]
    }
    template_variable {
      name = "realm"
      values = ["eu1"]
    }
  }
  1. terraform plan

Important Factoids

This is particularly problematic when the presets are generated through list comprehensions: unless you can apply a constant order to the for_each argument, you will always get changes

References

No response

@joelmarty joelmarty added the bug label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant