smutel/terraform-provider-netbox

Invalid value for custom field

openmsk opened this issue · 2 comments

Summary

Version

Netbox version

3.3
3.4 

Terraform version

Terraform v0.13.7

Provider version

6.1.0

Issue details

Affected Data(s) / Resource(s)

  • data dcim_site
  • resource netbox_virtualization_vm
  • custom_field

Terraform Configuration Files

resource "netbox_virtualization_vm" "vm" {
  name        = "${var.vm_name}.${var.vm_domain}"
  comments    = var.vm_desc
  disk        = var.vm_disk_size
  memory      = var.vm_mem
  vcpus       = var.vm_cpu_cores
  platform_id = local.list_platform_id[var.vm_platform_id]
  cluster_id  = data.netbox_virtualization_cluster.cluster.id

  custom_field {
    name  = "vm_server_role"
    type  = "text"
    value = var.vm_server_role
  }
}

Terraform Output

Error: response status code does not match any response statuses defined for this endpoint in the swagger spec (status 400): {}

  on .terraform/modules/test3_terraform.netbox/netbox.tf line 2, in resource "netbox_virtualization_vm" "vm":
   2: resource "netbox_virtualization_vm" "vm" {

Behaviors

Actual Behavior

Error: [POST /virtualization/virtual-machines/][400] virtualization_virtual-machines_create default  map[__all__:[Invalid value for custom field 'vm_server_role': Invalid choice (ansibles). Available choices are: ansible, sftp, sharepoint, smtp, som-cache, sphinx-travel, srv-common]]

  on .terraform/modules/test3_terraform.netbox/netbox.tf line 52, in resource "netbox_virtual_machine" "vm":
  52: resource "netbox_virtual_machine" "vm" {

Expected Behavior

If a custom field contains a choice of values, and a new value is specified in hcl, then the provider needs to report the response from the netbox.

Steps to Reproduce

  1. terraform apply

Hello. What you want in this issue is to improve the error message or to add the missing value throught terraform ?

hello, i would like terraform to report an error like the e-breuninger provider

Error: [POST /virtualization/virtual-machines/][400] 
virtualization_virtual-machines_create default  map[__all__:
[Invalid value for custom field 'vm_server_role': Invalid choice (ansibles). 
Available choices are: 1c, analytics, ansible, apache-airflow, appnginx, artifactory, zookeeper]]

  on .terraform/modules/test3_terraform.netbox/netbox.tf line 52, in resource "netbox_virtual_machine" "vm":
  52: resource "netbox_virtual_machine" "vm" {