4 "github.com/hashicorp/terraform/configs"
5 "github.com/hashicorp/terraform/dag"
8 // FlatConfigTransformer is a GraphTransformer that adds the configuration
9 // to the graph. The module used to configure this transformer must be
12 // This transform adds the nodes but doesn't connect any of the references.
13 // The ReferenceTransformer should be used for that.
15 // NOTE: In relation to ConfigTransformer: this is a newer generation config
16 // transformer. It puts the _entire_ config into the graph (there is no
17 // "flattening" step as before).
18 type FlatConfigTransformer struct {
19 Concrete ConcreteResourceNodeFunc // What to turn resources into
21 Config *configs.Config
24 func (t *FlatConfigTransformer) Transform(g *Graph) error {
25 // We have nothing to do if there is no configuration.
30 return t.transform(g, t.Config)
33 func (t *FlatConfigTransformer) transform(g *Graph, config *configs.Config) error {
34 // If we have no configuration then there's nothing to do.
39 // Transform all the children.
40 for _, c := range config.Children {
41 if err := t.transform(g, c); err != nil {
46 module := config.Module
47 // For now we assume that each module call produces only one module
48 // instance with no key, since we don't yet support "count" and "for_each"
50 // FIXME: As part of supporting "count" and "for_each" on modules, rework
51 // this so that we'll "expand" the module call first and then create graph
52 // nodes for each module instance separately.
53 instPath := config.Path.UnkeyedInstanceShim()
55 for _, r := range module.ManagedResources {
56 addr := r.Addr().Absolute(instPath)
57 abstract := &NodeAbstractResource{
61 // Grab the address for this resource
62 var node dag.Vertex = abstract
63 if f := t.Concrete; f != nil {