Hello,
We’re using Terraform with the Vultr and NetBox providers, and for no clear reason it started throwing errors related to “vm.config_context is object with no attributes”
Debugging locally, it seems the provider is receiving EOF from the server:
provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
provider: plugin process exited: (netbox)
Looking at NetBox /api manually with GET requests, everything seems to be in order and is returning the expected JSON data. Has anyone experienced this or have any idea why it would happen?
The only recent changes to netbox have been introducing new VMs to a 2nd cluster and enabling an additional IP prefix.
Thanks
main.tf:
data "netbox_json_virtualization_virtual_machines_list" "inventory" {
limit = 0
}
resource "vultr_instance" "netboxvm" {
for_each = {
for vm in local.full_json : vm.display => {
label = try(vm.config_context.label, vm.config_context.hostname)
hostname = vm.config_context.hostname
plan = try(vm.config_context.plan, "N/A")
os_id = vm.config_context.os_id
region = vm.config_context.region
backups = try(vm.config_context.backups, "disabled")
backups_schedule = try(vm.config_context.backups_schedule, null)
vpc_ids = try(vm.config_context.vpc_ids, null)
script_id = try(vm.config_context.script_id, null)
ssh_key_ids = try(vm.config_context.ssh_key_ids, null)
tags = try(local.vm_tags[vm.display], null)
}
}
hostname = each.value.hostname
label = each.value.label
plan = each.value.plan
os_id = each.value.os_id
region = each.value.region
backups = each.value.backups
script_id = each.value.script_id
ssh_key_ids = each.value.ssh_key_ids
tags = each.value.tags
dynamic "backups_schedule" {
for_each = each.value.backups_schedule
content {
dom = backups_schedule.value.dom
dow = backups_schedule.value.dow
hour = backups_schedule.value.hour
type = backups_schedule.value.type
}
}
vpc_ids = each.value.vpc_ids
}
locals {
full_json = jsondecode(data.netbox_json_virtualization_virtual_machines_list.inventory.json)
vm_tags = { for vm in local.full_json : vm.display => [for tag in vm.tags : tag.name] }
}