From 55eb06929efb43d1a6b67a790de58bd08de76c82 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 7 Jul 2014 15:37:50 -0700 Subject: [PATCH] terraform: fix cycle that could happen during destroy --- terraform/graph.go | 3 --- terraform/graph_test.go | 1 + terraform/test-fixtures/graph-diff-destroy/main.tf | 4 ++++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/terraform/graph.go b/terraform/graph.go index 56ef94bc0..61fb94cea 100644 --- a/terraform/graph.go +++ b/terraform/graph.go @@ -284,12 +284,9 @@ func graphAddDiff(g *depgraph.Graph, d *Diff) error { newNode.Resource.Diff = &ResourceDiff{Destroy: true} // Append it to the list so we handle it later - deps := make([]*depgraph.Dependency, len(n.Deps)) - copy(deps, n.Deps) newN := &depgraph.Noun{ Name: fmt.Sprintf("%s (destroy)", newNode.Resource.Id), Meta: newNode, - Deps: deps, } nlist = append(nlist, newN) diff --git a/terraform/graph_test.go b/terraform/graph_test.go index a83b10c47..1b38be511 100644 --- a/terraform/graph_test.go +++ b/terraform/graph_test.go @@ -276,6 +276,7 @@ const testTerraformGraphDiffDestroyStr = ` root: root aws_instance.bar aws_instance.bar -> aws_instance.bar (destroy) + aws_instance.bar -> aws_instance.foo aws_instance.bar (destroy) aws_instance.foo aws_instance.foo -> aws_instance.foo (destroy) diff --git a/terraform/test-fixtures/graph-diff-destroy/main.tf b/terraform/test-fixtures/graph-diff-destroy/main.tf index ca956330c..da9db4e0c 100644 --- a/terraform/test-fixtures/graph-diff-destroy/main.tf +++ b/terraform/test-fixtures/graph-diff-destroy/main.tf @@ -1,2 +1,6 @@ resource "aws_instance" "foo" { } + +resource "aws_instance" "bar" { + foo = "${aws_instance.foo.id}" +}