I’m finding more and more that I have a map (or a module) that is simply a listing of arguments to another module. Currently I need to either:
- refactor the module to take the whole map as its argument – this is only viable when all the values have the exact same provenance, or else the dependency graph quickly becomes tangled and cyclic
- unpack the map/module item by item – this can contribute as much as 30% of all lines in my tf code, and obviously has lots of room for typo and other human error
It ends up looking like
module "module_b" {
source = "../module_b"
a = local.args.a
b = local.args.b
c = local.args.c
d = local.args.d
}
In this thread I’d like to discuss adding a piece of syntax to improve this situation. Some obvious options:
module "module_b" {
source = "../module_b"
...local.args.a # add a second but similar purpose to the existing ... token
vars = local.args # a new meta-argument -- probably not
}
The engine would only accept this when the value is statically determined to be a map with known keys. I believe terraform already has some behaviors of that kind.
If you can think of a more idiomatic notation that’s forward-compatible with current modules, please let me know.