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

Tags not working when updating netbox-clusters #69

Closed
ps-misc opened this issue Sep 10, 2021 · 1 comment
Closed

Tags not working when updating netbox-clusters #69

ps-misc opened this issue Sep 10, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ps-misc
Copy link

ps-misc commented Sep 10, 2021

Terraform Version

terraform v0.14.9
provider v0.2.2
netbox v2.10.10

Affected Resource(s)

netbox-cluster

Terraform Configuration Files

provider "netbox" {
  server_url            = var.netbox_server
  api_token             = var.netbox_api_token
  allow_insecure_https  = true
}

resource "netbox_cluster" "cluster" {
    name = var.netbox_cluster.name
    cluster_type_id = var.netbox_cluster.cluster_type_id
    tags = [
      var.netbox_cluster.env,
      var.netbox_cluster.client
    ]
}

variable "netbox_cluster" {
  type = object({
    name = string
    cluster_type_id = number
    env = string
    client = string
  })
}
netbox_cluster = {
    name = "test"
    cluster_type_id = 2
    env = "test"
    client = "infra"
}

Expected Behavior

Terraform should update the cluster test and add the Tags "test" and "infra"

Actual Behavior

Terraform states the following error:
Error: [PATCH /virtualization/clusters/{id}/][400] virtualization_clusters_partial_update default map[tags:[This field may not be null.]]
on main.tf line 72, in resource "netbox_cluster" "cluster":
72: resource "netbox_cluster" "cluster" {

Steps to Reproduce

  1. terraform apply

Root Cause

Tags are not set inside the update function of the Cluster-Resource.
(terraform-provider-netbox/netbox/resource_netbox_cluster.go: func resourceNetboxClusterUpdate)

Recommended Bugfig

add "tags, _ := getNestedTagListFromResourceDataSet(api, d.Get("tags"))
data.Tags = tags"
to terraform-provider-netbox/netbox/resource_netbox_cluster.go inside the function resourceNetboxClusterUpdate.

@fbreckle fbreckle self-assigned this Sep 16, 2021
@fbreckle fbreckle added the bug Something isn't working label Sep 16, 2021
@fbreckle
Copy link
Collaborator

Indeed, tags seem to not be covered by the tests for the cluster resource. This should be fixed as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants