terraform-provider-netbox
terraform-provider-netbox copied to clipboard
[Feature request] - Support custom fields and multiple tags in `netbox_prefixes` datasource filter
Terraform Version
Terraform v1.4.0 on darwin_amd64
- provider registry.terraform.io/e-breuninger/netbox v3.2.1
Affected Resource(s)
Please list the resources as a list, for example:
- netbox_prefixes
Proposed Functionality
netbox_prefixes
should allow filtering of prefixes by custom fields as well as by more than one tag.
In addition, depth and length would be useful to filter on as well.
Justification/Use Case
We have a hierarchy of prefixes with a /14 representing a top level grouping, /16 a secondary level, and tenant groups get ranges below that. These groupings are represented in netbox via custom fields and/or tags. When finding an available prefix for a new tenant, it is not currently possible via the netbox_prefixes datasource to find the appropriate parent prefix e.g:
give me the /16 prefix which has these custom field values or these multiple tags
The best solution we can find so far is to aggregate multiple custom fields into a single tag and use that to filter, which is not ideal.
I tried my hand at getting multiple tags working and will submit a PR once I add tests and possibly try to address some of the other proposed fields. I can see it is hard to chose which of the MANY available fields to expose via this datasource and why it isnt practical to support them all
PR to implicitly enable all standard fields (not just the small number currently explicitly supported) and allow multiple tag filters. Haven't been able to get custom fields working though: https://github.com/e-breuninger/terraform-provider-netbox/pull/428