appoptics / terraform-provider-appoptics

Apache License 2.0
4 stars 2 forks source link

Tags for appoptics_dashboard_chart are ephemeral #54

Open poleszcz opened 1 year ago

poleszcz commented 1 year ago

Let's say we create chart like this:

resource "appoptics_dashboard_chart" "example_chart" {
  space_id   = appoptics_dashboard.example_dashboard.id
  name       = "Example Chart"
  #depends_on = [appoptics_metric.metric_two]
  min        = 0
  max        = 100
  label      = "Used"
  type       = "line"

  stream {
    metric      = appoptics_metric.metric_two.name
    color       = "#fa7268"
    units_short = "%"
    units_long  = "Percentage used"

    tags {
      name   = "environment"
      values = ["staging"]
    }
  }
}

AppOptics API doesn't return tags ...

curl \
>   -i \
>   -u $APPOPTICS_TOKEN: \
>   -X GET \
>   'https://api.appoptics.com/v1/spaces/1486654/charts/30584833'
HTTP/2 200
date: Tue, 27 Sep 2022 21:12:21 GMT
content-type: application/json
content-length: 188
server: roundhouse
strict-transport-security: max-age=31536000; includeSubDomains

{"id":30584833,"name":"Example Chart","type":"line","streams":[{"color":"#fa7268","units_short":"%","id":76476173,"metric":"example_metric_two","type":"gauge"}],"max":100.0,"label":"Used"}v

and terraform as well, during the next terraform plan, says that tags were removed...

 # appoptics_dashboard_chart.example_chart has been changed
  ~ resource "appoptics_dashboard_chart" "example_chart" {
        id            = "30584833"
        name          = "Example Chart"
        # (6 unchanged attributes hidden)

      + stream {
          + color       = "#fa7268"
          + max         = 0
          + metric      = "example_metric_two"
          + min         = 0
          + period      = 0
          + units_short = "%"
        }
      - stream {
          - color       = "#fa7268" -> null
          - metric      = "example_metric_two" -> null
          - units_long  = "Percentage used" -> null
          - units_short = "%" -> null

          - tags {
              - name   = "environment" -> null
              - values = [
                  - "staging",
                ] -> null
            }
        }
    }
poleszcz commented 1 year ago

Maybe the issue is that ... there must be already tagged data for metric... to define tags for chart.