Resource/Module argument splatting
Community note
[!TIP] 👋 Hi there, OpenTofu community! The OpenTofu team prioritizes issues based on upvotes. Please make sure to upvote this issue and describe how it affects you in detail in the comments to show your support.
OpenTofu Version
OpenTofu v1.9.1
The problem in your OpenTofu project
A common pattern is to wrap a resource as a module to accept an object or list of objects that contains the resource arguments, for example:
module "data_output" {
source = "./foo"
foo = "bar"
bleh = "foo"
}
module "implementation" {
obj = module.data_output.obj
}
Attempted Solutions
Wrapping resources in modules
Proposal
Ideally resources and modules would support splatting of args so this could be simplified to something like:
module "data_output" {
source = "./foo"
foo = "bar"
bleh = "foo"
}
resource "implementation" "splatting" {
args = module.data_output.obj
}
This removes the burden of having to maintain a module that simply wraps some resources.
Workarounds and Alternatives
More modules
References
No response
Thanks for this feature request, @nwmcsween! I've added this to the list of issues for the core team to discuss, and we'll comment again once we've discussed it.
(The following is not an answer on behalf of the core team, since we've not discussed it together yet.)
Introducing a new "meta-argument" for resource, data, module, provider, or provisioner blocks is a breaking change because meta-arguments in those contexts potentially shadow arguments defined by the underlying object. For example, if the resource type "implementation" shown in the example already defined an argument named args then any existing module currently defining that argument would change meaning if we redefined args as a meta-argument.
This is the same problem that blocks the current form of https://github.com/opentofu/opentofu/pull/2299. Perhaps we can find a solution that could benefit both of these proposals together.