Terraform: enabling the output of a child module

The output of a Terraform child module is not shown by the root configuration/module.  In order to have the child module output shown, you must explicitly define a root level output.

For example, if you root had a child module defined like below, and you wanted to display the output of that child module, then you would use this configuration.

module "child" {
  source = "./mymodule"
}

# explicitly show ALL output from child module
output "child-output" {
  value = module.child
}

And if the child module had multiple output defined, and you wanted to only display a specific one (e.g. ‘foo’), you would use a dotted notation like below.

# explicitly show single output definition from child module
output "child-output-foo" {
  value = module.child.foo
}

 

REFERENCES

stackoverflow.com, terraform output not working in module

stackoverflow.com, outputs not displaying when using modules

stackoverflow.com, cannot get outputs when terraform output is run