dynatrace-oss / terraform-provider-dynatrace

Apache License 2.0
71 stars 33 forks source link

Automatically generate empty tags when deploying dynatrace_http_monitor in terraform #523

Closed zjhnb11 closed 2 months ago

zjhnb11 commented 2 months ago

Describe the bug Hi, when I tried to update the version (from 1.44.1 to 1.65.0), I found that the dynatrace_http_monitor resource automatically generated an empty tag. This problem did not occur in the original version(1.44.1).

# module.http_monitors.dynatrace_http_monitor.AA will be updated in-place
  ~ resource "dynatrace_http_monitor" "AA" {
        id                     = "HTTP_CHECK-XXXXX"
        name                   = "AA"
        # (5 unchanged attributes hidden)
      ~ tags {
          - tag {
              - context = "CONTEXTLESS" -> null
              - key     = "1212" -> null
              - source  = "USER" -> null
                # (1 unchanged attribute hidden)
            }
          + tag {
              + context = "CONTEXTLESS"
              + key     = "1212"
                # (2 unchanged attributes hidden)
            }
          + tag {
                # (1 unchanged attribute hidden)
            }
        }

        # (2 unchanged blocks hidden)
    }

When I perform the action. It appears the error:

╷
│ Error: size must be between 1 and 2000
│ 
│   with module.http_monitors.dynatrace_http_monitor.AA,
│   on modules/http_monitors/http_monitor_AA.tf line 2, in resource "dynatrace_http_monitor" "AA":
│    2: resource "dynatrace_http_monitor" "AA" {
│ 

To Reproduce

just apply this resource

resource "dynatrace_http_monitor" "AA" {
  name      = "AA"
       .......

  tags {
    tag {
      context = "CONTEXTLESS"
      key     = "1212"
    }
  }
}

Expected behavior It should not create the empty tag.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

Even when I only keep tags block,

tags {

  }

it will generate empty tag. Although I didn't define any tag in it.

Reinhard-Pilz-Dynatrace commented 2 months ago

Hello @zjhnb11

The issue you're experiencing originates from a bug within the Terraform SDK we've observed in various other resources already. It is related to unordered sub blocks (i.e. SETS of blocks) where Terraform generates plans that contain these empty entries.

What's a bit unusual here is that it doesn't emerge with 1.44.1 but only the recent version of the provider. I've checked the history of this resource and that doesn't reveal any changes related since then.

Nevertheless, we are able to work around the above mentioned bug in the Terraform Plugin SDK. I've committed the fix a couple of minutes ago. You plans will STILL show these empty entries, but the provider will handle them properly.

The upcoming release of the provider will contain this fix.

zjhnb11 commented 2 months ago

Hi @Reinhard-Pilz-Dynatrace ,

Thanks for your work.