-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terraform 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 |
Is this duplicated from #27351? |
@sergioUjo Yes, thanks for catching that! I can confirm the bug is now fixed, due to changes merged in #27352. Closing. |
I have exactly the same issue with |
The backport is merged (thanks @aliscott!) and scheduled for the 0.14.7 release. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
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
The text was updated successfully, but these errors were encountered: