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

tfe_workspace_ids support to filter excluding specific tags

Open devopsrick opened this issue 4 years ago • 2 comments

It would be nice to be able to exclude specific tags from the data source. i.e. all workspaces with tags "aws" and "app" but NOT "prod".

data "tfe_workspace_ids" "non-prod-apps" {
  tag_names    = [!"prod", "app", "aws"]
  organization = "my-org-name"
}

devopsrick avatar Nov 17 '21 17:11 devopsrick

I did accomplish the same effect by using setsubtract(), but it would be much cleaner if the data lookup supported the idea of excluding specific tags from the results.

setsubtract(values(data.tfe_workspace_ids.aws.ids), values(data.tfe_workspace_ids.aws_prod.ids))

devopsrick avatar Nov 22 '21 12:11 devopsrick

We can add a exclude_tags field to this data source that will locally filter from the returned set. How does this sound?

sebasslash avatar Jun 09 '22 21:06 sebasslash

This was released as part of v0.32.0 earlier this year

brandonc avatar Dec 23 '22 16:12 brandonc