terraform-provider-netbox
terraform-provider-netbox copied to clipboard
netbox_virtual_machine custom_fields multiple selection type
Hi there,
I Have a problem to use "Custom field" with multiple selection in netbox_virtual_machine definition.
I use e-breuninger/netbox provider in version 1.6.7 because the new versions "2.0.0" and "2.0.1" does not work. I will create another issue for that.
Terraform Version
$ terraform -v
Terraform v1.2.3
on linux_amd64
+ provider registry.terraform.io/e-breuninger/netbox v1.6.7
Affected Resource(s)
Please list the resources as a list, for example:
- netbox_virtual_machine
Terraform Configuration Files
I have try two configurations. server_role field is custom field of type "Multiple selection".
Configuration 1:
resource "netbox_virtual_machine" "XXX" {
cluster_id = netbox_cluster.XXX.id
name = "XXXX"
platform_id = netbox_platform.XXX.id
custom_fields = {
"server_role" = "value1, value2"
}
}
Error:
╷
│ Error: [PUT /virtualization/virtual-machines/{id}/][400] virtualization_virtual-machines_update default map[__all__:[Invalid value for custom field 'server_role': Invalid choice(s) (v, a, l, u, e, 1, ,, , v, a, l, u, e, 2,). Available choices are: value1, value2, value3]]
│
│ with netbox_virtual_machine.XXX[0],
│ on XXX.tf line 3, in resource "netbox_virtual_machine" "XXX":
│ 3: resource "netbox_virtual_machine" "XXX" {
│
╵
Releasing state lock. This may take a few moments...
ERRO[0065] 1 error occurred:
* exit status 1
Configuration 2:
resource "netbox_virtual_machine" "XXX" {
cluster_id = netbox_cluster.XXX.id
name = "XXXX"
platform_id = netbox_platform.XXX.id
custom_fields = {
"server_role" = ["app", "search"]
}
}
Error:
│ Error: Incorrect attribute value type
│
│ on XXX.tf line 10, in resource "netbox_virtual_machine" "XXX":
│ 10: custom_fields = {
│ 11: server_role = ["app", "search"]
│ 12: }
│ ├────────────────
│
│ Inappropriate value for attribute "custom_fields": element "server_role":
│ string required.
╵
ERRO[0019] 1 error occurred:
* exit status 1
I have an error because "custom_fields " attribute type is "Map of string".
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform apply
Regards,
This problem is always present with the last provider version.
e-breuninger/netbox provider version: 2.0.4 Netbox version: 3.2.6
Plan:
~ resource "netbox_virtual_machine" "ec2" {
~ custom_fields = {
~ "server_role" = "app, shares" -> "app, shares"
Error:
│ Error: [PUT /virtualization/virtual-machines/{id}/][400] virtualization_virtual-machines_update default map[__all__:[Invalid value for custom field 'server_role': Invalid choice(s) (a, p, p, ,, , s, h, a, r, e, s,). Available choices are: app, shares,]]
│
│ with netbox_virtual_machine.ec2[0],
│ on netbox_ec2.tf line 3, in resource "netbox_virtual_machine" "ec2":
│ 3: resource "netbox_virtual_machine" "ec2" {
│
ERRO[0068] 1 error occurred:
* exit status 1
Regards,
Hello,
Do you need extra informations to debug this problem ?
Regards,