e-breuninger / terraform-provider-netbox

Terraform provider to interact with Netbox
https://registry.terraform.io/providers/e-breuninger/netbox/latest/docs
Mozilla Public License 2.0
173 stars 117 forks source link

Allow netbox_custom_field to accept `object` as type, and specify `object_type` #593

Closed ad8lmondy closed 1 month ago

ad8lmondy commented 2 months ago

go-netbox has these additional values defined: https://github.com/fbreckle/go-netbox/blob/2513e68359ff2e42cfc1deed72034bd8ff1dee8e/netbox/models/custom_field.go#L989-L999

But the provider rejects them as invalid.

Tested OK on my personal netbox.

ad8lmondy commented 1 month ago

As per the tests, and my own usage - when resources do not have a custom_field set, terraform wants to remove the item:

        Terraform will perform the following actions:

          # netbox_prefix.test will be updated in-place
          ~ resource "netbox_prefix" "test" {
              ~ custom_fields = {
                  - "test" = null
                }
                id            = "19"
                # (10 unchanged attributes hidden)
            }

        Plan: 0 to add, 1 to change, 0 to destroy.

However, this always happens. If I set the resource to have:

custom_fields = {
  test = null
}

Terraform treats the test field as omitted, and so it can never seem to be satisfied.

Not really sure how to get around this issue :(

ad8lmondy commented 1 month ago

This is a poor substitute for the work started here: https://github.com/e-breuninger/terraform-provider-netbox/pull/242