diff --git a/terraform/transform_expand.go b/terraform/transform_expand.go index 85d6602063..440c522f39 100644 --- a/terraform/transform_expand.go +++ b/terraform/transform_expand.go @@ -1,6 +1,7 @@ package terraform import ( + "fmt" "log" "github.com/hashicorp/terraform/dag" @@ -59,3 +60,26 @@ func (n *GraphNodeBasicSubgraph) Name() string { func (n *GraphNodeBasicSubgraph) Subgraph() *Graph { return n.Graph } + +func (n *GraphNodeBasicSubgraph) Flatten(p []string) (dag.Vertex, error) { + return &graphNodeBasicSubgraphFlat{ + GraphNodeBasicSubgraph: n, + PathValue: p, + }, nil +} + +// Same as GraphNodeBasicSubgraph, but for flattening +type graphNodeBasicSubgraphFlat struct { + *GraphNodeBasicSubgraph + + PathValue []string +} + +func (n *graphNodeBasicSubgraphFlat) Name() string { + return fmt.Sprintf( + "%s.%s", modulePrefixStr(n.PathValue), n.GraphNodeBasicSubgraph.Name()) +} + +func (n *graphNodeBasicSubgraphFlat) Path() []string { + return n.PathValue +}