'Terraform filter data source if tag doesn't exist

I'm trying to filter an aws_subnet data source, and one of the criteria is that a tag does not exist.

data "aws_subnet" "selected" {
  filter {
    name   = "tag:environment"
    values = ["foobar"]
  }
  filter {
    name   = "tag:thistagdoesnotexist"
    values = [""]
  }
}

Is this possible? and if not, is there a potential workaround without adding the tag to every resource?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source