6 "github.com/hashicorp/terraform/addrs"
7 "github.com/hashicorp/terraform/configs"
8 "github.com/hashicorp/terraform/states"
11 // OrphanOutputTransformer finds the outputs that aren't present
12 // in the given config that are in the state and adds them to the graph
14 type OrphanOutputTransformer struct {
15 Config *configs.Config // Root of config tree
16 State *states.State // State is the root state
19 func (t *OrphanOutputTransformer) Transform(g *Graph) error {
21 log.Printf("[DEBUG] No state, no orphan outputs")
25 for _, ms := range t.State.Modules {
26 if err := t.transform(g, ms); err != nil {
33 func (t *OrphanOutputTransformer) transform(g *Graph, ms *states.Module) error {
40 // Get the config for this path, which is nil if the entire module has been
42 var outputs map[string]*configs.Output
43 if c := t.Config.DescendentForInstance(moduleAddr); c != nil {
44 outputs = c.Module.Outputs
47 // An output is "orphaned" if it's present in the state but not declared
48 // in the configuration.
49 for name := range ms.OutputValues {
50 if _, exists := outputs[name]; exists {
54 g.Add(&NodeOutputOrphan{
55 Addr: addrs.OutputValue{Name: name}.Absolute(moduleAddr),