vmware / terraform-provider-avi

Terraform AVI Networks provider
https://registry.terraform.io/providers/vmware/avi/
Mozilla Public License 2.0
31 stars 32 forks source link

avi provider is reading and importing resources with a minimal set of attributes #543

Open itskvad opened 1 year ago

itskvad commented 1 year ago

Describe the bug

I have imported an existing resource

terraform import avi_healthmonitor.healthcheck-tcp-test healthmonitor-e3f60d20 

tf code for said resource:

resource "avi_healthmonitor" "healthcheck-tcp-test" {
    name = "healthcheck-tcp-test"
    tenant_ref = var.tenant_ref
    receive_timeout = 4
    failed_checks = 2
    send_interval = 10
    successful_checks = 2
    type = "HEALTH_MONITOR_TCP"
    tcp_monitor {
        tcp_half_open        = "false"
    }
}

Import successful!

Now run a terraform plan

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # avi_healthmonitor.healthcheck-tcp-test will be updated in-place
  ~ resource "avi_healthmonitor" "healthcheck-tcp-test" {
      + failed_checks     = "2"
        id                = "https://xyz"
      + is_federated      = "false"
        name              = "healthcheck-tcp-test"
      + receive_timeout   = "4"
      + send_interval     = "10"
      + successful_checks = "2"
        # (4 unchanged attributes hidden)

      + tcp_monitor {
          + maintenance_response = (known after apply)
          + tcp_half_open        = "false"
          + tcp_request          = (known after apply)
          + tcp_response         = (known after apply)
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Running a terraform plan shows that the resource is going to make changes to the resource, even though the resource is already imported and has the correct values.

Resource values in state after a import: terraform state show avi_healthmonitor.healthcheck-tcp-test

# avi_healthmonitor.healthcheck-tcp-test:
resource "avi_healthmonitor" "healthcheck-tcp-test" {
id = [https://xyz]
monitor_port = "443"
name = "healthcheck-tcp-test"
tenant_ref = [https://xyz]
type = "HEALTH_MONITOR_TCP"
uuid = "healthmonitor-e3f60d20"
}

The avi provider is reading and importing the resource with a minimal set of attributes.

Reproduction steps

  1. import resource from avi - health monitor in this case
  2. check values of imported resource ...

Expected behavior

Import all the existing values that are set in the health monitor. Terraform plan should not attempt to set the values if the values are already in the resource.

Additional context

No response

rmcolbert commented 5 months ago

Along the same vein, avi_healthmonitor (in v22.1.6 and 30.2.1) is recreating the protocol based monitor blocks on every apply, not simply the first after an import.