Preserve map-like values when read from an input file

My use case is to read from a dynamic env file a mix of string literals and var.* to pass them as env variables, however, I can’t preserve them like var.region becomes "var.region" (string literal) after parsing them.
Is there a much better way to preserve such so they can be interpolated when reading from an input file?

Env file:

REGION=var.region
FOO="bar"

main.tf

environment_variables = { for k, v in toset(split("\n", file("${path.module}/lambda/${each.key}/environment_variables"))) : trim(split("=", k)[0], "\"") => trim(split("=", k)[1], "\"") }


}

Plan output:

      + environment {
          + variables = {
              + "FOO"    = "bar"
              + "REGION" = "var.region"
            }
        }

Required plan output:

      + environment {
          + variables = {
              + "FOO"    = "bar"
              + "REGION" = "eu-west-2"  #interpolated by var.region
            }
        }

Terraform does not support that.

You will need to move your environment variable definitions into actual native .tf files, in the Terraform language, rather than loading them from a different text format using string manipulation.

Cracked it.
With a bit of using locals{} and lookup(), I can pass both interpolated vars and literal strings. The key to lookup() value is assign a unique-enough keyword like lookup_ (could be as unique as you like), so it’s developer/user friendly when scaling instances of the module.

TF config:
main.tf

locals {
  lookup_map = {
    lookup_region         = var.region
    lookup_ddb_table_name = aws_dynamodb_table.this.name
  }
}

...
  environment_variables = {
    for k, v in each.value["environment_variables"] : k => lookup(local.lookup_map, v, v)
  }

variables.tf

variable "api_names" {
  description = "(Optional) Map of API names in Appsync data source"
  type        = map(any)
  default     = {}
}

terraform.tfvars

api_names = {
  create_foo = {
    field_name = "createFoo"
    type_name  = "Mutation"
    environment_variables = {
      REGION                = "lookup_region"
      foo                   = "bar"
      TABLE                 = "lookup_ddb_table_name"
    }
  }
}

TF plan output:

      + environment {
          + variables = {
              + "REGION"     = "eu-west-2" #interpolated from lookup_map
              + "foo"        = "bar"
              + "TABLE"      = "baz-ddb-table" #interpolated from lookup_map
            }
        }

Now, I can just reuse/repeat the module using for_each, happy days!