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

netbox_device_interface tagged_vlans do not validate/resolve against existing vlan objects

Open fire-ant opened this issue 1 year ago • 1 comments

Issue Reporting Guide

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

3.3.0

Affected Resource(s)

  • netbox_device_interface

Terraform Configuration Files

Um these are converted to crossplane CR's which are a representation of the terraform configs in a Kubernetes controller

---
apiVersion: dcim.netbox.upbound.io/v1alpha1
kind: DeviceInterface
metadata:
  name: test-device-interface
spec:
  forProvider:
    enabled: true
    deviceIdRef:
      name: test-device
    macAddress: DE:AD:BE:EF:00:00
    mgmtonly: false
    mode: access
    mtu: 1500
    taggedVlans:
      - 10
      - 20
    tags:
      - thing
    type: 1000base-t
    untaggedVlan: 30

Debug Output

https://gist.github.com/fire-ant/f19ef2e46e1c2ac1e7228d88877a8039

Expected Behavior

the pre create vlans should have been correctly resolved from the list of integers. When I create vlans I am not statically assigning object ids which match the vlan IDs. I dont think that would be programmatically wise or should be necessary.

I see https://github.com/e-breuninger/terraform-provider-netbox/blob/cfb2e54ec5f61a6cdc0f63297709418555127ea0/netbox/resource_netbox_device_interface.go#L263

suggests that the ID's are returned but my expectation would be that the lookup uses the VID rather than the object ID.

Actual Behavior

The IDs never resolve to valid VLANs. This is because the function assumes that there is a 1-2-1 mapping between the VID number and the object number which shouldn't be the case (unless I'm misunderstanding how this works)

Steps to Reproduce

I can publish work and repro steps if necessary

Important Factoids

I think the important thing to know is Im wrapping the netbox provider in terraform. That shouldn't affect its underlying behaviour but may be exposing assumptions around the providers usage

References

Nope!

fire-ant avatar Jun 08 '23 19:06 fire-ant

Can you somehow reproduce your problem with only terraform? I have trouble following here.

fbreckle avatar Jul 24 '23 13:07 fbreckle