smutel / terraform-provider-netbox

Terraform provider for Netbox
ISC License
58 stars 19 forks source link

Tenant Name limited to 30 chars #182

Closed boopzz closed 1 year ago

boopzz commented 1 year ago

Summary

The tenant creation resource has a hard limit of 30 characters for a name. I was hoping to set up a tenant per subscription I have in azurem, some of which have longer names than 30 characters. I've tested in the GUI and it seems you can have as long as you want (but I'm guessing no longer than 100 chars), although the slug tries to truncate to 50 chars but you can manually override. The API suggests that the max is 100 characters for the tenant name and the tenant slug so I can't seem to find why this 30 character limit exists.

We are migrating from a department Netbox to a unified one across our Business and are moving from an older version to a newer version that's why I'm testing on 2 separate instances.

I don't have access to the latest Netbox but will try and build one and report back if the same issue.

Version

Netbox version

2.10.10
3.2.5

Terraform version

1.3.9

Provider version

2.2.1
5.3.1

Issue details

Affected Data(s) / Resource(s)

Terraform Configuration Files

locals {
    tenant_name = "THIS_is_a_test_tenant_name_of_like_43_chars"
}

resource "netbox_tenancy_tenant" "main" {
  name            = local.tenant_name
  slug            = lower(local.tenant_name)
}

terraform {
  required_providers {
    netbox = {
      source = "smutel/netbox"
      # https://github.com/smutel/terraform-provider-netbox/blob/master/README.md#compatibility-with-netbox
      # versions match a specific Netbox version
      version = "~>5.0"
    }
  }
  required_version = ">= 1.0"
}

Terraform Output

╷
│ Error: expected length of name to be in the range (1 - 30), got THIS_is_a_test_tenant_name_of_like_43_chars
│ 
│   with netbox_tenancy_tenant.main,
│   on main.tf line 6, in resource "netbox_tenancy_tenant" "main":
│    6:   name            = local.tenant_name
│ 
╵

Behaviors

Actual Behavior

Terraform errors out saying it's expecting a value to be 1-30 in length

Expected Behavior

I was expecting the tenant to be created with the requested name upto the length set by netbox which looking at the API Swagger spec suggests 100 chars for the name and 100 chars for the slug

Steps to Reproduce

  1. Have a Netbox instance reachable with a user token to use
  2. Setup access to Netbox with 2x envars, NETBOX_URL and NETBOX_TOKEN
  3. Copy the test code
  4. Change the smutel/netbox provider version to one matching your version of Netbox
  5. terraform init -upgrade
  6. terraform plan
boopzz commented 1 year ago

I've just spun the latest image of Netbox and it has the same issue as previously tested. Still whinges about the name being 30 chars over.

Netbox version: 3.4.5 Terraform version: 1.3.9 Provider version: 6.1.0