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
18 stars 14 forks source link

Fix error when optional node/fex interfaces key is not present #2

Closed andbyrne closed 1 year ago

andbyrne commented 1 year ago

Example of error:

Error: Unsupported attribute

  on /modules/aci/main.tf line 39, in locals:
  39:         node.id if length([for int in node.interfaces : try(int.policy_group, null) if try(int.policy_group, null) == pg.name]) > 0

This object does not have an attribute named "interfaces".

Data model triggering error:

apic:
  interface_policies:
    nodes:
      - id: 101

Workaround is to add empty interfaces key however the preference is to update the code given the interfaces key is not mandatory in the data model schema, and a similar try statement exists for these keys on lines 14 and 15.

Workaround:

apic:
  interface_policies:
    nodes:
      - id: 101
        interfaces: []