newrelic / terraform-provider-newrelic

Terraform provider for New Relic
https://registry.terraform.io/providers/newrelic/newrelic/latest/docs
Mozilla Public License 2.0
200 stars 244 forks source link

Resource `newrelic_one_dashboard`: Unable to add float thresholds to `widget_line` #2703

Open juwatanabe opened 6 days ago

juwatanabe commented 6 days ago

Terraform Version

Terraform v1.7.5

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Actual Behavior

When trying to create a resource_newrelic_one_dashboard with a widget_line threshold with non integer type the provider is erroring. See below terraform to create widget_line

   widget_line {
      title  = "Node Request/Capacity"
      nrql_query {
        query = "SELECT latest(cpuRequestedCores)/max(capacityCpuCores) as cpuRequestPercent, latest(memoryRequestedBytes)/max(capacityMemoryBytes) as memRequestPercent FROM K8sNodeSample WHERE clusterName = {{cluster}} and `label.node-pool` in ({{node_pool}}) FACET aparse(hostname, '*.%') TIMESERIES 1 minute"
      }
      units {
        unit = "percentage"
      }
      is_label_visible = true
      threshold {
        name     = "Request Warn"
        from     = 0.9
        to       = 0.95
        severity = "warning"
      }
    }

When trying to apply I get the below errors:

│ Error: Attribute must be a whole number, got 0.9
│
│   with module.standard-deploy.module.by-cluster.newrelic_one_dashboard.filter_by_cluster,
│   on newrelic/modules/dashboards/by-cluster/main.tf line 240, in resource "newrelic_one_dashboard" "filter_by_cluster":
│  240:         severity = "warning"
│
│ Error: Attribute must be a whole number, got 0.95
│
│   with module.standard-deploy.module.by-cluster.newrelic_one_dashboard.filter_by_cluster,
│   on newrelic/modules/dashboards/by-cluster/main.tf line 240, in resource "newrelic_one_dashboard" "filter_by_cluster":
│  240:         severity = "warning"

Expected Behavior

Resource should be created successfully

Steps to Reproduce

  1. terraform apply

Important Factoids

From looking at the code for dashboardWidgetLineSchemaElem() I believe the type just needs to be adjusted from Int to Float. https://github.com/newrelic/terraform-provider-newrelic/blob/6cc65d093fd7aaf48a78a59ee8b2bd80000e5654/newrelic/resource_newrelic_one_dashboard.go#L607

pranav-new-relic commented 6 days ago

@juwatanabe thanks for reporting this - this issue is already on our radar via other internal feedback we've received. We shall be prioritizing this based on our current task queue.