diff --git a/CHANGELOG.md b/CHANGELOG.md index 937293549930..81b5b898ed7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ BUG FIXES: diffing lists. [GH-661] * core: fix crash where module inputs weren't strings, and add more validation around invalid types here. [GH-624] + * core: fix error when using a computed module output as an input to + another module. [GH-659] * provider/aws: Fix crash case when internet gateway is not attached to any VPC. [GH-664] * provider/aws: `vpc_id` is no longer required. [GH-667] diff --git a/terraform/context.go b/terraform/context.go index 324fb6778e33..49c5da1ef483 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -1623,10 +1623,7 @@ func (c *walkContext) computeModuleVariable( // Get that module from our state mod := c.Context.state.ModuleByPath(path) if mod == nil { - return "", fmt.Errorf( - "Module '%s' not found for variable '%s'", - strings.Join(path[1:], "."), - v.FullKey()) + return "", nil } value, ok := mod.Outputs[v.Field] diff --git a/terraform/context_test.go b/terraform/context_test.go index dcaccc355bc7..c547ec2daac4 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -4362,6 +4362,22 @@ func TestContextRefresh_moduleInputComputedOutput(t *testing.T) { } } +func TestContextRefresh_moduleVarModule(t *testing.T) { + m := testModule(t, "refresh-module-var-module") + p := testProvider("aws") + p.DiffFn = testDiffFn + ctx := testContext(t, &ContextOpts{ + Module: m, + Providers: map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + }) + + if _, err := ctx.Refresh(); err != nil { + t.Fatalf("err: %s", err) + } +} + // GH-70 func TestContextRefresh_noState(t *testing.T) { p := testProvider("aws")