How do I expose submodule state in root module for terraform 0.12 use

What is the process for exposing state in submodules in the root module so that the ‘output’ command will work with Terraform 0.12

I’m trying to migrate our infrastructure to use terraform 0.12 and am seeing an issue that I’m not sure of the proper way to resolve.

I have a nested module structure:

root
root/usw2
root/usw2/eks
root/usw2/rds

I used to use the following commands to access the submodules output:

terraform output -module=usw2.eks kubeconfig
terraform output -module=usw2.rds dburl

When I run those commands now I see the following:

Error: Unsupported option

The -module option is no longer supported since Terraform 0.12, because now
only root outputs are persisted in the state.

What is the method for exposing the outputs of submodules in the root state? I did not see this documented in https://www.terraform.io/upgrade-guides/0-12.html documentation.

Many thanks in advance!

Never mind. I figured it out. Just expose the whole module in outputs all the way back up to root module.

2 Likes