site24x7 / terraform-provider-site24x7

Terraform provider for Site24x7
MIT License
22 stars 33 forks source link

tag_names is not idempotent #285

Open valugi opened 2 months ago

valugi commented 2 months ago

hi, This is about the SSL monitor, but I guess the implementation would be the same everywhere where there is a tag_ids/tag_names. https://registry.terraform.io/providers/site24x7/site24x7/latest/docs/resources/ssl_monitor So I associate tags to this monitor and I apply, they apply correctly. But on the next run, the tag is detected as new. The same applies to user_group_names.


  ~ resource "site24x7_ssl_monitor" "ssl_monitor" {
        id                        = "396627000019682039"
      ~ tag_ids                   = [
          - "396627000019682015",
        ]
      ~ user_group_ids            = [
          - "396627000019683052",
          - "396627000019675047",
          - "396627000019681043",
        ]```
valugi commented 2 months ago

So this is probably related with the fact that I have specified default values. This is my setup, I do have an empty tag_ids - that should be ignored for being empty.

  tag_ids                   = []
  tag_names             = ["TAG_A"]

Right?

PS. The user solution is to change from this:

variable "tag_ids" {
  type    = list(string)
  default = []
}

to this:

variable "tag_ids" {
  type    = list(string)
  default = null
}

Though, to be frank, I like it more when the default is the same type as the definition. Maybe you can add an extra check on your side.

Regards