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

Filter by Tag name on data sources #261

Open
ironashram opened this issue Oct 6, 2022 · 2 comments
Open

Filter by Tag name on data sources #261

ironashram opened this issue Oct 6, 2022 · 2 comments

Comments

@ironashram
Copy link
Contributor

ironashram commented Oct 6, 2022

Hi,
i would like to extend the tags capability of the provider, specifically allowing the data sources to filter by tag name, in particular for our current use case it would be needed for devices and virtual_machines data sources, but i guess it can be applied even more widely.
Before getting down to it deeply i wanted to discuss a bit the eventual implementation as it may not be acceptable for you.

I have done some quick experiments, please note that the patches below are only an indication

  • Option 1

https://github.com/e-breuninger/terraform-provider-netbox/compare/master...ironashram:terraform-provider-netbox:tags_experiment_1?expand=1

Which returns something like

                  + tags            = [
                      + {
                          + description = ""
                          + id          = 27
                          + name        = "ceph-mon"
                          + slug        = "ceph-mon"
                        },
                      + {
                          + description = ""
                          + id          = 24
                          + name        = "controlplane"
                          + slug        = "controlplane"
                        },
                      + {
                          + description = ""
                          + id          = 26
                          + name        = "etcd"
                          + slug        = "etcd"
                        },
                      + {
                          + description = ""
                          + id          = 23
                          + name        = "spare-blade"
                          + slug        = "spare-blade"
                        },

  • Option 2

https://github.com/e-breuninger/terraform-provider-netbox/compare/master...ironashram:terraform-provider-netbox:tags_experiment_2?expand=1

Which returns something like

                  + tag_ids        = [
                      + 27,
                      + 24,
                      + 26,
                      + 23,
                    ]
                  + tag_names      = [
                      + "ceph-mon",
                      + "controlplane",
                      + "etcd",
                      + "spare-blade",
                    ]

In principle i really prefer the first option as it seems more consistent with the netbox api, but on the other hand implementing that on all resources would be a breaking change.

Let me know what is your vision on this

@kyle-burnett
Copy link
Contributor

+1

I think the ability to filter existing resources by tag is much needed functionality within the provider.

To accomplish this currently, we need to use a lot of external data sources to query the Netbox API directly. Being able to do this with "real" terraform data resources would be awesome.

@fbreckle
Copy link
Collaborator

fbreckle commented Jan 9, 2023

I agree that we should go with Option 1. This came back on my plate due to #321.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants