terraform-provider-netbox icon indicating copy to clipboard operation
terraform-provider-netbox copied to clipboard

Bind tags to resources through a "binding" resource

Open qaoru opened this issue 2 years ago • 2 comments

Hello :)

We are using this provider extensively with the IPAM and tagging resources, and we are currently trying to reorganize our workflow (with lots of VMs, environments, ...). However, there is one thing that we'd like to do : add tags to resources declared in a specific state from another state. We currently have one Terraform state managing common IPAM resources such as prefixes and generic tags (like production, develop, ...). What we're looking for is the possibility to create a tag from another state (i.e. related to a cluster of VMs), and to add it to a prefix.

Basically, we're looking for a behavior like things that you can find on IaaS providers with resources that binds disks to VMs, or VMs to a load-balancer pool.

Affected Resource(s)

Please list the resources as a list, for example:

  • netbox_tag
  • netbox_prefix
  • ... (anything that supports tagging)

Example Behavior

resource "netbox_tag" "ceph" {
  name      = "ceph_nodes"
  color_hex = "ff00ff"
}

data "netbox_prefix" "storage_subnet" {
  cidr = "10.42.0.0/16"
}

resource "netbox_prefix_tag_binding" "ceph" {
  prefix_id = data.netbox_prefix.storage_subnet.id
  tag         = netbox_tag.ceph.name
}

I think I'd be able to make a PR for a feature like this, but I'd like to gather some thoughts about it to know if that might be interesting to add to the provider. There might be some parameters to add to resources to avoid breaking things when reapplying the terraform code that manages the prefixes when a list of tags is already given.

Any thoughts ?

qaoru avatar Sep 28 '22 17:09 qaoru

I think this could be a nice feature. I'm not sure if it is possible via the Netbox Api, but if possible feel free to send an PR.

FlxPeters avatar Oct 01 '22 13:10 FlxPeters

how to create child prefix using this terraform provider?

bsabri2023 avatar Nov 29 '22 19:11 bsabri2023