terraform-provider-avi icon indicating copy to clipboard operation
terraform-provider-avi copied to clipboard

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

Open itskvad opened this issue 1 year ago • 1 comments

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

itskvad avatar May 16 '23 23:05 itskvad