4 "github.com/hashicorp/terraform/configs"
7 // LocalTransformer is a GraphTransformer that adds all the local values
8 // from the configuration to the graph.
9 type LocalTransformer struct {
10 Config *configs.Config
13 func (t *LocalTransformer) Transform(g *Graph) error {
14 return t.transformModule(g, t.Config)
17 func (t *LocalTransformer) transformModule(g *Graph, c *configs.Config) error {
19 // Can't have any locals if there's no config
23 // Our addressing system distinguishes between modules and module instances,
24 // but we're not yet ready to make that distinction here (since we don't
25 // support "count"/"for_each" on modules) and so we just do a naive
26 // transform of the module path into a module instance path, assuming that
27 // no keys are in use. This should be removed when "count" and "for_each"
28 // are implemented for modules.
29 path := c.Path.UnkeyedInstanceShim()
31 for _, local := range c.Module.Locals {
32 addr := path.LocalValue(local.Name)
40 // Also populate locals for child modules
41 for _, cc := range c.Children {
42 if err := t.transformModule(g, cc); err != nil {