netascode / terraform-aci-nac-aci

Terraform Cisco ACI Nexus-as-Code Module
https://registry.terraform.io/modules/netascode/nac-aci/aci
Apache License 2.0
17 stars 14 forks source link

Dependency issue with `terraform-aci-pod-setup` module #77

Closed andbyrne closed 1 week ago

andbyrne commented 2 months ago

This error was reported:

╷
│ Error: The post rest request failed
│ 
│   with module.aci.module.aci_pod_setup["2"].aci_rest_managed.fabricExtRoutablePodSubnet["172.31.3.0/24"],
│   on .terraform/modules/aci/modules/terraform-aci-pod-setup/main.tf line 11, in resource "aci_rest_managed" "fabricExtRoutablePodSubnet":
│   11: resource "aci_rest_managed" "fabricExtRoutablePodSubnet" {
│ 
│ Code: 400 Response: [map[error:map[attributes:map[code:102 text:configured object ((Dn0)) not found Dn0=uni/controller/setuppol/setupp-2/extrtpodsubnet-[172.31.3.0/24],
│ ]]]], err: %!s(<nil>). Please report this issue to the provider developers.
╵ 

The configuration applied successfully in a subsequent apply operation.

I believe the terraform-aci-pod-setup module needs a dependency on the aci_rest_managed.fabricSetupP resource to be added to the aci_rest_managed.fabricExtRoutablePodSubnet resource.

Proposed solution:

resource "aci_rest_managed" "fabricExtRoutablePodSubnet" {
  for_each   = { for extpool in var.external_tep_pools : extpool.prefix => extpool }
  dn         = "uni/controller/setuppol/setupp-${var.pod_id}/extrtpodsubnet-[${each.value.prefix}]"
  class_name = "fabricExtRoutablePodSubnet"
  content = {
    pool                = each.value.prefix
    reserveAddressCount = each.value.reserved_address_count
    state               = "active"
  }

  depends_on = [
    aci_rest_managed.fabricSetupP
  ]
}
danischm commented 1 month ago

Fixed here: https://github.com/netascode/terraform-aci-nac-aci/commit/6d1250859428ab9cefeea0432f3a5032112d1fc1