diff --git a/command/jsonconfig/config.go b/command/jsonconfig/config.go index ecfa12c5e9..0b27c7af4b 100644 --- a/command/jsonconfig/config.go +++ b/command/jsonconfig/config.go @@ -238,6 +238,11 @@ func marshalModuleCalls(c *configs.Config, schemas *terraform.Schemas) map[strin } func marshalModuleCall(c *configs.Config, mc *configs.ModuleCall, schemas *terraform.Schemas) moduleCall { + // It is possible to have a module call with a nil config. + if c == nil { + return moduleCall{} + } + ret := moduleCall{ Source: mc.SourceAddr, VersionConstraint: mc.Version.Required.String(), diff --git a/command/test-fixtures/show-json/nested-modules/main.tf b/command/test-fixtures/show-json/nested-modules/main.tf new file mode 100644 index 0000000000..ef0bad2bbc --- /dev/null +++ b/command/test-fixtures/show-json/nested-modules/main.tf @@ -0,0 +1,3 @@ +module "my_module" { + source = "./modules" +} diff --git a/command/test-fixtures/show-json/nested-modules/modules/main.tf b/command/test-fixtures/show-json/nested-modules/modules/main.tf new file mode 100644 index 0000000000..990155ecb3 --- /dev/null +++ b/command/test-fixtures/show-json/nested-modules/modules/main.tf @@ -0,0 +1,3 @@ +module "more" { + source = "./more-modules" +} diff --git a/command/test-fixtures/show-json/nested-modules/modules/more-modules/main.tf b/command/test-fixtures/show-json/nested-modules/modules/more-modules/main.tf new file mode 100644 index 0000000000..488a271930 --- /dev/null +++ b/command/test-fixtures/show-json/nested-modules/modules/more-modules/main.tf @@ -0,0 +1,4 @@ +variable "misspelled" { + default = "ehllo" + descriptoni = "I am a misspelled attribute" +} diff --git a/command/test-fixtures/show-json/nested-modules/output.json b/command/test-fixtures/show-json/nested-modules/output.json new file mode 100644 index 0000000000..75f15466e7 --- /dev/null +++ b/command/test-fixtures/show-json/nested-modules/output.json @@ -0,0 +1,23 @@ +{ + "format_version": "0.1", + "terraform_version": "0.12.1-dev", + "planned_values": { + "root_module": {} + }, + "configuration": { + "root_module": { + "module_calls": { + "my_module": { + "source": "./modules", + "module": { + "module_calls": { + "more": { + "module": {} + } + } + } + } + } + } + } +} \ No newline at end of file