From ef60ac5b8ceee14a1919df4697434f8bd0308208 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 16 Dec 2014 08:24:21 -0800 Subject: [PATCH] terraform: update comment --- terraform/context.go | 6 ++++++ .../test-fixtures/refresh-module-var-module/bar/main.tf | 3 +++ .../test-fixtures/refresh-module-var-module/foo/main.tf | 7 +++++++ terraform/test-fixtures/refresh-module-var-module/main.tf | 8 ++++++++ 4 files changed, 24 insertions(+) create mode 100644 terraform/test-fixtures/refresh-module-var-module/bar/main.tf create mode 100644 terraform/test-fixtures/refresh-module-var-module/foo/main.tf create mode 100644 terraform/test-fixtures/refresh-module-var-module/main.tf diff --git a/terraform/context.go b/terraform/context.go index 49c5da1ef..72166f8d6 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -1623,6 +1623,12 @@ func (c *walkContext) computeModuleVariable( // Get that module from our state mod := c.Context.state.ModuleByPath(path) if mod == nil { + // If the module doesn't exist, then we can return an empty string. + // This happens usually only in Refresh() when we haven't populated + // a state. During validation, we semantically verify that all + // modules reference other modules, and graph ordering should + // ensure that the module is in the state, so if we reach this + // point otherwise it really is a panic. return "", nil } diff --git a/terraform/test-fixtures/refresh-module-var-module/bar/main.tf b/terraform/test-fixtures/refresh-module-var-module/bar/main.tf new file mode 100644 index 000000000..46ea37f14 --- /dev/null +++ b/terraform/test-fixtures/refresh-module-var-module/bar/main.tf @@ -0,0 +1,3 @@ +variable "value" {} + +resource "aws_instance" "bar" {} diff --git a/terraform/test-fixtures/refresh-module-var-module/foo/main.tf b/terraform/test-fixtures/refresh-module-var-module/foo/main.tf new file mode 100644 index 000000000..2ee798058 --- /dev/null +++ b/terraform/test-fixtures/refresh-module-var-module/foo/main.tf @@ -0,0 +1,7 @@ +output "output" { + value = "${aws_instance.foo.foo}" +} + +resource "aws_instance" "foo" { + compute = "foo" +} diff --git a/terraform/test-fixtures/refresh-module-var-module/main.tf b/terraform/test-fixtures/refresh-module-var-module/main.tf new file mode 100644 index 000000000..76775e3e6 --- /dev/null +++ b/terraform/test-fixtures/refresh-module-var-module/main.tf @@ -0,0 +1,8 @@ +module "foo" { + source = "./foo" +} + +module "bar" { + source = "./bar" + value = "${module.foo.output}" +}