terraform: fix cycle that could happen during destroy
This commit is contained in:
parent
1c725896ca
commit
55eb06929e
|
@ -284,12 +284,9 @@ func graphAddDiff(g *depgraph.Graph, d *Diff) error {
|
||||||
newNode.Resource.Diff = &ResourceDiff{Destroy: true}
|
newNode.Resource.Diff = &ResourceDiff{Destroy: true}
|
||||||
|
|
||||||
// Append it to the list so we handle it later
|
// Append it to the list so we handle it later
|
||||||
deps := make([]*depgraph.Dependency, len(n.Deps))
|
|
||||||
copy(deps, n.Deps)
|
|
||||||
newN := &depgraph.Noun{
|
newN := &depgraph.Noun{
|
||||||
Name: fmt.Sprintf("%s (destroy)", newNode.Resource.Id),
|
Name: fmt.Sprintf("%s (destroy)", newNode.Resource.Id),
|
||||||
Meta: newNode,
|
Meta: newNode,
|
||||||
Deps: deps,
|
|
||||||
}
|
}
|
||||||
nlist = append(nlist, newN)
|
nlist = append(nlist, newN)
|
||||||
|
|
||||||
|
|
|
@ -276,6 +276,7 @@ const testTerraformGraphDiffDestroyStr = `
|
||||||
root: root
|
root: root
|
||||||
aws_instance.bar
|
aws_instance.bar
|
||||||
aws_instance.bar -> aws_instance.bar (destroy)
|
aws_instance.bar -> aws_instance.bar (destroy)
|
||||||
|
aws_instance.bar -> aws_instance.foo
|
||||||
aws_instance.bar (destroy)
|
aws_instance.bar (destroy)
|
||||||
aws_instance.foo
|
aws_instance.foo
|
||||||
aws_instance.foo -> aws_instance.foo (destroy)
|
aws_instance.foo -> aws_instance.foo (destroy)
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
resource "aws_instance" "foo" {
|
resource "aws_instance" "foo" {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "aws_instance" "bar" {
|
||||||
|
foo = "${aws_instance.foo.id}"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue