Hi,
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:
- main.tf
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
}
-
variables.tf
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 variables.tf
and terraforms.tfvar
files completely in each folder and keep only the main.tf
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,
Vojta