diff --git a/terraform/context_test.go b/terraform/context_test.go index 9ebe5766bb..f89fda0cc7 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -139,6 +139,27 @@ func TestContext2Validate_moduleGood(t *testing.T) { } } +func TestContext2Validate_moduleBadResource(t *testing.T) { + m := testModule(t, "validate-module-bad-rc") + p := testProvider("aws") + c := testContext2(t, &ContextOpts{ + Module: m, + Providers: map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + }) + + p.ValidateResourceReturnErrors = []error{fmt.Errorf("bad")} + + w, e := c.Validate() + if len(w) > 0 { + t.Fatalf("bad: %#v", w) + } + if len(e) == 0 { + t.Fatalf("bad: %#v", e) + } +} + func TestContext2Validate_orphans(t *testing.T) { p := testProvider("aws") m := testModule(t, "validate-good") @@ -480,27 +501,6 @@ func TestContext2Validate_varRefFilled(t *testing.T) { } /* -func TestContextValidate_moduleBadResource(t *testing.T) { - m := testModule(t, "validate-module-bad-rc") - p := testProvider("aws") - c := testContext(t, &ContextOpts{ - Module: m, - Providers: map[string]ResourceProviderFactory{ - "aws": testProviderFuncFixed(p), - }, - }) - - p.ValidateResourceReturnErrors = []error{fmt.Errorf("bad")} - - w, e := c.Validate() - if len(w) > 0 { - t.Fatalf("bad: %#v", w) - } - if len(e) == 0 { - t.Fatalf("bad: %#v", e) - } -} - func TestContextValidate_moduleProviderInherit(t *testing.T) { m := testModule(t, "validate-module-pc-inherit") p := testProvider("aws") diff --git a/terraform/graph.go b/terraform/graph.go index f8698c37e4..cc5c5a6b20 100644 --- a/terraform/graph.go +++ b/terraform/graph.go @@ -173,6 +173,17 @@ func (g *Graph) walk(walker GraphWalker) error { } } + // If the node has a subgraph, then walk the subgraph + if sn, ok := v.(GraphNodeSubgraph); ok { + log.Printf( + "[DEBUG] vertex %s: walking subgraph", + dag.VertexName(v)) + + if rerr = sn.Subgraph().walk(walker); rerr != nil { + return + } + } + return nil }