6 "github.com/hashicorp/terraform/config/module"
7 "github.com/hashicorp/terraform/dag"
10 // FlatConfigTransformer is a GraphTransformer that adds the configuration
11 // to the graph. The module used to configure this transformer must be
14 // This transform adds the nodes but doesn't connect any of the references.
15 // The ReferenceTransformer should be used for that.
17 // NOTE: In relation to ConfigTransformer: this is a newer generation config
18 // transformer. It puts the _entire_ config into the graph (there is no
19 // "flattening" step as before).
20 type FlatConfigTransformer struct {
21 Concrete ConcreteResourceNodeFunc // What to turn resources into
26 func (t *FlatConfigTransformer) Transform(g *Graph) error {
27 // If no module, we do nothing
32 // If the module is not loaded, that is an error
33 if !t.Module.Loaded() {
34 return errors.New("module must be loaded")
37 return t.transform(g, t.Module)
40 func (t *FlatConfigTransformer) transform(g *Graph, m *module.Tree) error {
41 // If no module, no problem
46 // Transform all the children.
47 for _, c := range m.Children() {
48 if err := t.transform(g, c); err != nil {
53 // Get the configuration for this module
56 // Write all the resources out
57 for _, r := range config.Resources {
58 // Grab the address for this resource
59 addr, err := parseResourceAddressConfig(r)
65 // Build the abstract resource. We have the config already so
66 // we'll just pre-populate that.
67 abstract := &NodeAbstractResource{
71 var node dag.Vertex = abstract
72 if f := t.Concrete; f != nil {