diff --git a/terraform/context.go b/terraform/context.go index 9fa97ca86..f64056d87 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -959,6 +959,7 @@ func (c *walkContext) persistState(r *Resource) { rs.init() module.Resources[r.Id] = rs } + rs.Dependencies = r.Dependencies // Assign the instance state to the proper location if r.Flags&FlagTainted != 0 { @@ -1148,5 +1149,3 @@ func (c *walkContext) computeResourceMultiVariable( return strings.Join(values, ","), nil } - - diff --git a/terraform/graph.go b/terraform/graph.go index 056813e9c..73c3d837f 100644 --- a/terraform/graph.go +++ b/terraform/graph.go @@ -79,7 +79,6 @@ type GraphNodeModule struct { type GraphNodeResource struct { Index int Config *config.Resource - Dependencies []string Resource *Resource ResourceProviderID string } @@ -264,7 +263,7 @@ func graphEncodeDependencies(g *depgraph.Graph) { } // Update the dependencies - rn.Dependencies = inject + r.Dependencies = inject } } diff --git a/terraform/graph_test.go b/terraform/graph_test.go index 9b223d58b..e9220ce84 100644 --- a/terraform/graph_test.go +++ b/terraform/graph_test.go @@ -594,12 +594,12 @@ func TestGraphEncodeDependencies(t *testing.T) { // This should encode the dependency information into the state graphEncodeDependencies(g) - web := g.Noun("aws_instance.web").Meta.(*GraphNodeResource) + web := g.Noun("aws_instance.web").Meta.(*GraphNodeResource).Resource if len(web.Dependencies) != 1 || web.Dependencies[0] != "aws_security_group.firewall" { t.Fatalf("bad: %#v", web) } - weblb := g.Noun("aws_load_balancer.weblb").Meta.(*GraphNodeResource) + weblb := g.Noun("aws_load_balancer.weblb").Meta.(*GraphNodeResource).Resource if len(weblb.Dependencies) != 1 || weblb.Dependencies[0] != "aws_instance.web" { t.Fatalf("bad: %#v", weblb) } @@ -637,12 +637,12 @@ func TestGraphEncodeDependencies_count(t *testing.T) { // This should encode the dependency information into the state graphEncodeDependencies(g) - web := g.Noun("aws_instance.web.0").Meta.(*GraphNodeResource) + web := g.Noun("aws_instance.web.0").Meta.(*GraphNodeResource).Resource if len(web.Dependencies) != 0 { t.Fatalf("bad: %#v", web) } - weblb := g.Noun("aws_load_balancer.weblb").Meta.(*GraphNodeResource) + weblb := g.Noun("aws_load_balancer.weblb").Meta.(*GraphNodeResource).Resource if len(weblb.Dependencies) != 3 { t.Fatalf("bad: %#v", weblb) } diff --git a/terraform/resource.go b/terraform/resource.go index 20614536b..a9115fb91 100644 --- a/terraform/resource.go +++ b/terraform/resource.go @@ -29,6 +29,7 @@ type Resource struct { Id string Info *InstanceInfo Config *ResourceConfig + Dependencies []string Diff *InstanceDiff Provider ResourceProvider State *InstanceState diff --git a/terraform/state.go b/terraform/state.go index a6988b195..8d3b9d934 100644 --- a/terraform/state.go +++ b/terraform/state.go @@ -42,7 +42,7 @@ type State struct { // // This should be the preferred method to add module states since it // allows us to optimize lookups later as well as control sorting. -func (s *State) AddModule(path []string) *ModuleState{ +func (s *State) AddModule(path []string) *ModuleState { m := &ModuleState{Path: path} m.init() s.Modules = append(s.Modules, m) @@ -125,7 +125,7 @@ func (s *State) String() string { // If we're the root module, we just write the output directly. if reflect.DeepEqual(m.Path, rootModulePath) { - buf.WriteString(mStr+"\n") + buf.WriteString(mStr + "\n") continue }