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

Add in filter block option for data lookups #68

Open
finkjordanj opened this issue Jun 5, 2024 · 0 comments
Open

Add in filter block option for data lookups #68

finkjordanj opened this issue Jun 5, 2024 · 0 comments
Labels
api API Bug enhancement New feature or request

Comments

@finkjordanj
Copy link

Is your feature request related to a problem? Please describe.
Add in an option of filter blocks within terraform so that I can do a data lookup on an object with multiple returns but only have it return based on a filter options. This would help when needing to lookup a network id based on a tag/name/other value.

Currently if i need to lookup a existing network id. i must do a data lookup on all my networks and then using a terraform loop i can loop through and set a local value of what I am trying to get.

For me to get one network id i must first pull in all the networks and then loop through until i can find the one with the correct name.
While it works it does make my state file much larger than it needs due to the data lookup ultimately returning all networks instead of just the one.

data "meraki_networks" "dev_networks" {
  organization_id = local.organization_id
}

locals {
  this_network = [for network in data.meraki_networks.dev_networks.items : network if network.name == "750-comm-meraki-lab"][0]
}

Describe the solution you'd like
If we can add in a filter block similar to the AWS's registery filter block on their data lookups.

data "meraki_networks" "dev_networks" {
  organization_id = local.organization_id
  filter {
    name = "name"
    value = "750-comm-meraki-lab"
  }
}

If this works then the name would equal the key in the returned and value would be the value on the lookup. This would ideally then do the loop for me ahead of actually storing anything in state and only store the returned value of the one ID.

Describe alternatives you've considered
The current workaround does work, but each site will essentially be storing all sites ids rather than just their own.

Additional context
I am not familiar enough with Go to know exactly how AWS Terraform base code does their filter as their registry is quite extensive.

@obrigg obrigg added the enhancement New feature or request label Jun 10, 2024
@fmunozmiranda fmunozmiranda added the api API Bug label Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api API Bug enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants