Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upterraform show -json module map is empty #25494
Comments
Hi @wilson-codeminus, From the steps listed here, I would not expect there to be anything in the state, since there has not been anything applied. |
Yes. You're right, I forgot to add |
Thanks @wilson-codeminus, I'm not sure how to reproduce this yet. Is it possible to create an example showing the module configuration as well? |
Ok. I will expand to show the module and submodule as well. |
I'm seeing something similar where resources defined in a module that is itself defined in a module don't appear in I'm trying to cut my config down to the minimum to reproduce this, will update if I work it out |
Here's a very simple reproduction: main.tf module "a" {
source = "./a"
} a/main.tf: module "b" {
source = "./b"
} a/b/main.tf: resource "null_resource" "none" {} Reproduction:
Confirmed on Terraform 0.12.28 and 0.13.3. |
I believe the issue is in this loop: terraform/command/jsonstate/state.go Lines 199 to 208 in 6d7904c For my simple repro case above, this results in a This results in an empty output, because the following line only considers modules starting from root: terraform/command/jsonstate/state.go Lines 210 to 211 in 6d7904c The solution to this will have to ensure that we can cope with intermediate modules which do not have any resources, but do have child modules. It's not immediately obvious to me how we fix this, but I think it will be isolated to Workaround: for anyone else hitting this bug, adding a |
Terraform Version
Terraform Configuration Files
Debug Output
https://gist.github.com/wilson-codeminus/41d0951d92c1bd253e5ea12c62aceb5b
Crash Output
N/A
Expected Behavior
Expected to get a JSON representation of the resources present within the terraform state file
Actual Behavior
Module map object is empty:
Steps to Reproduce
terraform init
terraform apply
terraform show -json
Additional Context
N/A
References
N/A