Refactoring tfvars

I have monorepo with over 100 subfolders, each containing an almost identical combination of files. Differing ever so slightly in versions and values. Each subfolder contains:
- with several modules, each like this with a lot of the nested module variables mapped to top-level module variables

module "helm" {
  source = "git@gmodule-source?ref=version"

  a                                        = var.a
  b                                        = var.b
  c                                        = var.c
and many more assignments like this
  • defining all those variables, in every folder defining mostly the same variables and their defaults
  • terraform.tfvars that’s where the values are defined, only a small subset of the defined top-level variables have some values assigned
a = "foo"
c = "bar"

I would love to get rid of the and terraforms.tfvar files completely in each folder and keep only the with only the variables that have some non-default values directly assigned to module variables. Something like this:

module "helm" {
  source = "git@gmodule-source?ref=version"

  a                                        = "foo"
  c                                        = "bar"

Maybe somehow iterate over the tfvars file and set the appropriate variable with GitHub - minamijoyo/hcledit: A command line editor for HCL? Not sure yet.
I would be curious how you think it could be solved either with bash or Go or any other way. And I’d be grateful for any ideas or suggestions you might have.

Thank you,

Try terragrunt and you can just one .hcl file with all the values. And it should just work fine.

I don’t think you understood my question, but thank you for taking the time to respond.