Skip to content

netbox_prefix custom fields result in permanent state drift #712

@mattwilder

Description

@mattwilder

Provider version: 3.9.2
Netbox Version: v4.0.11-2.9.1

We are using the netbox_prefix resource with 3 custom fields:

  • account, a text field
  • cloud_account, a object reference to a circuit provider account
  • location, another text field

Here is an example terraform resource configuration

resource "netbox_prefix" "this" {
    custom_fields = {
        "account"       = "821287586161"
        "cloud_account" = "5"
        "location"      = "AWS US East (N. Virginia)"
    }
    description   = "aws-inquest-1"
    id            = "215"
    is_pool       = false
    mark_utilized = false
    prefix        = "10.255.168.0/21"
    role_id       = 0
    site_id       = 0
    status        = "active"
    tags          = []
    tenant_id     = 0
    vlan_id       = 0
    vrf_id        = 1
}

However, every time we run terraform plan, the cloud_account and location fields show up as to be added:

Terraform will perform the following actions:

  # module.netbox[0].netbox_prefix.this will be updated in-place
  ~ resource "netbox_prefix" "this" {
      ~ custom_fields = {
          + "cloud_account" = "5"
          + "location"      = "AWS US East (N. Virginia)"
            # (1 unchanged element hidden)
        }
        id            = "215"
        tags          = []
        # (10 unchanged attributes hidden)
    }

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

After running terraform apply, terraform state show shows that the location field is added, but as soon as terraform plan is run again the field is dropped. It looks like the cloud_account is never actually set inside terraform state

Additionally, all 3 custom fields are actually updated to the value provided, but the cloud_account and location custom fields still show up as not set on the next terraform plan as shown above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions