github.com/paybyphone/terraform@v0.9.5-0.20170613192930-9706042ddd51/terraform/transform_count_boundary.go (about) 1 package terraform 2 3 import ( 4 "github.com/hashicorp/terraform/dag" 5 ) 6 7 // CountBoundaryTransformer adds a node that depends on everything else 8 // so that it runs last in order to clean up the state for nodes that 9 // are on the "count boundary": "foo.0" when only one exists becomes "foo" 10 type CountBoundaryTransformer struct{} 11 12 func (t *CountBoundaryTransformer) Transform(g *Graph) error { 13 node := &NodeCountBoundary{} 14 g.Add(node) 15 16 // Depends on everything 17 for _, v := range g.Vertices() { 18 // Don't connect to ourselves 19 if v == node { 20 continue 21 } 22 23 // Connect! 24 g.Connect(dag.BasicEdge(node, v)) 25 } 26 27 return nil 28 }