-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Open
Labels
Description
Terraform Version
Terraform v1.13.4
on darwin_arm64Use Cases
- I have an internal module that sets up our basic application infrastructure and is used by a lot of apps. Occasionally I find I want to add an output and would like a way to have all the uses of the module output it too.
- For most projects, I create local modules and have multiple environments use it with different variable files. Each env has to output the module outputs.
Attempted Solutions
Currently I create an output for each module output in each app that uses it.
For local, I put the output blocks in a file then symbolic link it to each environment sub folder.
envs/
├─ dev/
│ ├─ outputs.tf -> ../outputs.tf
├─ prod/
│ ├─ outputs.tf -> ../outputs.tf
├─ outputs.tf
Could add the whole module as the output but that would require refactoring references to it.
Could use dynamic to loop through keys but still an extra step.
Proposal
Add a way to automatically pass outputs through from a module.
module "example" {
source = "..."
# default to false, True for all or list of keys
propagate_outputs = "False | True | List(string)"
}This would be the equivalent of
output "output_id" {
value = module.example.output_id
}Pitfalls would be if two modules shared an output name or a module was used twice. For that a prefix could be added propagate_outputs_prefix = "example_" which would create:
output "example_output_id" {
value = module.example.output_id
}Otherwise, throw an error on conflicts on the validation stage.
References
No response
supergibbs