vmware/terraform-provider-avi

Unable to reconcile state of resources modified outside Terraform

j-slater opened this issue · 1 comments

Description

The AVI Terraform provider seems to be unable to reconcile the state of AVI load balancer resources that are modified outside of Terraform. Normally Terraform is expected to compare the state of the infrastructure to its configured state and reconcile any deltas.

Steps to Reproduce

  1. Create a full AVI load balancer stack resembling the example provided in https://github.com/terraform-providers/terraform-provider-avi/blob/master/examples/basic/avi_example.tf (code provided below)

  2. Delete the load balancer stack outside of Terraform

  3. Attempt a terraform destroy or terraform apply to reconcile the load balancer state.

  4. An error is received Error: Encountered an error on GET request to URL https://<controller ip>/api/pool/pool-06468bb7-210b-4dc7-85eb-5929eed094b1: HTTP code: 404; error from Avi: map[error:Pool object not found!]

Expected Behavior

  • terraform destroy should succeed in clearing its state of resources when it determines those resources no longer exist in the infrastructure.
  • terraform apply should create resources that are missing.

Details

Versions

Terraform v0.12.21
+ provider.avi v0.2.1

The stack.tf file used for this test

provider "avi" {
  avi_username   = var.avi_username
  avi_password   = var.avi_password
  avi_controller = var.avi_controller
  avi_tenant     = "admin"
}

data "avi_tenant" "default_tenant" {
  name = "admin"
}

data "avi_cloud" "default_cloud" {
  name = var.default_cloud
}

data "avi_vrfcontext" "global_vrf" {
  name      = "global"
  cloud_ref = data.avi_cloud.default_cloud.id
}

data "avi_serviceenginegroup" "se_group" {
  name      = var.se_group
  cloud_ref = data.avi_cloud.default_cloud.id
}

resource "avi_vsvip" "testvip" {
  cloud_ref = data.avi_cloud.default_cloud.id
  name      = "testvip"
  vip {
    ip_address {
      type  = "V4"
      addr  = var.testvip
    }
  }
  tenant_ref = data.avi_tenant.default_tenant.id
}

resource "avi_virtualservice" "testvs" {
  name            = "testvs"
  pool_ref        = avi_pool.testpool.id
  cloud_ref       = data.avi_cloud.default_cloud.id
  tenant_ref      = data.avi_tenant.default_tenant.id
  vsvip_ref       = avi_vsvip.testvip.id
  vrf_context_ref = avi_pool.testpool.vrf_ref
  se_group_ref    = data.avi_serviceenginegroup.se_group.id
  services {
    port           = 80
    port_range_end = 80
  }
}

resource "avi_pool" "testpool" {
  name                         = "testpool"
  tenant_ref                   = data.avi_tenant.default_tenant.id
  cloud_ref                    = data.avi_cloud.default_cloud.id
  delete_server_on_dns_refresh = false
}

resource "avi_server" "testserver" {
  ip       = var.testserver
  port     = "80"
  pool_ref = avi_pool.testpool.id
}