CiscoDevNet / terraform-provider-aci

Terraform Cisco ACI provider
https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs
Mozilla Public License 2.0
91 stars 101 forks source link

`aci_fabric_node_member` resource do not remove node from inventory (DCNE-152) #1214

Closed edudppaz closed 1 month ago

edudppaz commented 6 months ago

Community Note

Terraform Version

v1.5.6

APIC version and APIC Platform

Affected Resource(s)

Terraform Configuration Files

resource "aci_fabric_node_member" "fabricNodes" {
  for_each = { for node in try(local.nodes, []) : node.id => node }
  name     = each.value.name
  serial   = each.value.serial_number
  node_id  = each.value.id
  pod_id   = each.value.pod
  role     = each.value.role
}

Debug Output

Panic Output

Expected Behavior

Upon destruction of the resource, the aci node should be removed from the fabric inventory.

Actual Behavior

A terraform apply reports the destruction of the resource, and the resource gets removed from the terraform state. However, the fabric node member is not removed from the fabric inventory.

2024-05-13T09:11:58.3126327Z module.tf-aci-setup[0].aci_fabric_node_member.fabricNodes["1136"]: Destruction complete after 0s

Steps to Reproduce

  1. terraform plan
  2. terraform apply

Important Factoids

The proper API call to remove the node from inventory is: https://<IP>/api/node/mo/uni/fabric/outofsvc.json

With body (example):

 {
  "fabricRsDecommissionNode": {
    "attributes": {
      "tDn": "topology/pod-1/node-1136",
      "status": "created,modified",
      "removeFromController": "true"
    }
  }
}

References

shrsr commented 6 months ago

@edudppaz Thank you for opening the issue. Our team will look into this and get back to you.

bardahlm commented 6 months ago

Just a comment regarding use of aci_fabric_node_member. When one switch needed to be replaced we got into trouble as Terraform wanted to remove the old switch, which did no longer exist. After this we changed to use serial number as key instead of hostname. The next time we had to replace a switch we had no problems, just imported the new switch into state after adding it to the fabric using the gui.