Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local_context_data on virtual machine is asking for a string but needs te be JSON #59

Closed
caskalverboer opened this issue Apr 29, 2021 · 1 comment · Fixed by #99 or smutel/go-netbox#23
Assignees
Labels
bug Something isn't working

Comments

@caskalverboer
Copy link

Summary

I can't use local_context_data on a virtual machine because the module asks for a string but the API for JSON.

Version

Netbox version

v2.9.9

Terraform version

0.15.1

Provider version

1.3.0

Issue details

Affected Data(s) / Resource(s)

  • resource netbox_virtualization_vm

Terraform Configuration Files

resource "netbox_virtualization_vm" "vm" {
  name            = vsphere_virtual_machine.vm.name
  disk            = vsphere_virtual_machine.vm.disk[0].size
  memory          = vsphere_virtual_machine.vm.memory
  cluster_id      = 4
  local_context_data = {"test": "test"}

  tag {
    name = "all"
    slug = "all"
  }

}

Terraform Output

When using a dict:
│ Error: Incorrect attribute value type
│ 
│   on vm.tf line 78, in resource "netbox_virtualization_vm" "vm":
│   78:   local_context_data = {"test": "test"} 
│ 
│ Inappropriate value for attribute "local_context_data": string required.

When using a string:
╷
│ Error: [POST /virtualization/virtual-machines/][400] virtualization_virtual-machines_create default  map[local_context_data:[JSON data must be in object form. Example: {"foo": 123}]]
│ 
│   on vm.tf line 73, in resource "netbox_virtualization_vm" "vm":
│   73: resource "netbox_virtualization_vm" "vm" {
│ 

Behaviors

Actual Behavior

The module only accepting a string for local_context_data meanwhile the API needs it in JSON format.

Expected Behavior

The module accepting JSON format for local_context_data

Steps to Reproduce

  1. terraform plan
  2. Terraform apply
@caskalverboer caskalverboer added the bug Something isn't working label Apr 29, 2021
@caskalverboer caskalverboer changed the title [Main title for your issue here] local_context_data on virtual machine is asking for a string but needs te be JSON Apr 29, 2021
@S0LERA
Copy link

S0LERA commented Mar 22, 2022

Hi, I am having the same behaviour with the new version (3.0.0) of the provider. If I specify the local_context_data, an error 400 occurs:

resource "netbox_virtualization_vm" "vm_test" {
  name = test
  cluster_id = 1
  local_context_data = "{\"test\": \"test\"}"
}
Error: response status code does not match any response statuses defined for this endpoint in the swagger spec (status 400): {}

I tried with and without double quotes: local_context_data = "{test: test}"

And, if json is specified instead of string (local_context_data = {"test": "test"}), a type error occurs:

Inappropriate value for attribute "local_context_data": string required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment