e-breuninger / terraform-provider-netbox

Terraform provider to interact with Netbox
https://registry.terraform.io/providers/e-breuninger/netbox/latest/docs
Mozilla Public License 2.0
175 stars 129 forks source link

[Feature request] - Support custom fields and multiple tags in `netbox_prefixes` datasource filter #425

Open tgoff opened 1 year ago

tgoff commented 1 year ago

Terraform Version

Terraform v1.4.0 on darwin_amd64

Affected Resource(s)

Please list the resources as a list, for example:

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.

tgoff commented 1 year ago

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

tgoff commented 1 year ago

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