diff --git a/terraform/context.go b/terraform/context.go index 34505e3cf..a8894a73f 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -956,7 +956,8 @@ func (c *walkContext) validateWalkFn() depgraph.WalkFunc { meta.Children = make(map[string]*walkValidateMeta) } - return func(n *depgraph.Noun) error { + var walkFn depgraph.WalkFunc + walkFn = func(n *depgraph.Noun) error { // If it is the root node, ignore if n.Name == GraphRootNode { return nil @@ -988,6 +989,11 @@ func (c *walkContext) validateWalkFn() depgraph.WalkFunc { panic("resource should never be nil") } + // If we're expanding, then expand the nodes, and then rewalk the graph + if rn.ExpandMode > ResourceExpandNone { + return c.genericWalkResource(rn, walkFn) + } + // If it doesn't have a provider, that is a different problem if rn.Resource.Provider == nil { return nil @@ -1060,6 +1066,8 @@ func (c *walkContext) validateWalkFn() depgraph.WalkFunc { return nil } + + return walkFn } func (c *walkContext) genericWalkFn(cb genericWalkFunc) depgraph.WalkFunc {