Modules are good when you want to group resources into components. However they don't provide a good way to re-use fragments of code between modules.
Terragrunt can be used to do this, but it is cumbersome to work with. Although it's motto is DRY (Don't repeat yourself), I found it needed a lot of boilerplate code which was hard to maintain.
What would be useful if there was a way to import a file into the scope of the current module.
OpenTofu Version
Use Cases
Modules are good when you want to group resources into components. However they don't provide a good way to re-use fragments of code between modules.
Terragrunt can be used to do this, but it is cumbersome to work with. Although it's motto is DRY (Don't repeat yourself), I found it needed a lot of boilerplate code which was hard to maintain.
What would be useful if there was a way to import a file into the scope of the current module.
Consider the following scenario
The deployment units are the Instance* modules. All of these need to use the same providers which define which environment to deploy to.
It would be useful to be able to either include the whole of the Shared folder in the current context or specify a single file to include.
Attempted Solutions
Terragrunt
Proposal
Add a new include block to include a whole folder or single file.
Or adapt the module block to have a flag that indicates that the module should be included in the current scope rather than a nested scope.
References
No response