terraform: copy the proper dependencies over on destroy plan
This commit is contained in:
parent
55eb06929e
commit
9f56fc8ddc
|
@ -283,11 +283,26 @@ func graphAddDiff(g *depgraph.Graph, d *Diff) error {
|
||||||
// Make the diff _just_ the destroy.
|
// Make the diff _just_ the destroy.
|
||||||
newNode.Resource.Diff = &ResourceDiff{Destroy: true}
|
newNode.Resource.Diff = &ResourceDiff{Destroy: true}
|
||||||
|
|
||||||
// Append it to the list so we handle it later
|
// Create the new node
|
||||||
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,
|
||||||
}
|
}
|
||||||
|
newN.Deps = make([]*depgraph.Dependency, 0, len(n.Deps))
|
||||||
|
for _, d := range n.Deps {
|
||||||
|
// We don't want to copy any resource dependencies
|
||||||
|
if _, ok := d.Target.Meta.(*GraphNodeResource); ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
newN.Deps = append(newN.Deps, &depgraph.Dependency{
|
||||||
|
Name: d.Name,
|
||||||
|
Source: newN,
|
||||||
|
Target: d.Target,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append it to the list so we handle it later
|
||||||
nlist = append(nlist, newN)
|
nlist = append(nlist, newN)
|
||||||
|
|
||||||
// Mark the old diff to not destroy since we handle that in
|
// Mark the old diff to not destroy since we handle that in
|
||||||
|
|
|
@ -277,11 +277,16 @@ 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 -> aws_instance.foo
|
||||||
|
aws_instance.bar -> provider.aws
|
||||||
aws_instance.bar (destroy)
|
aws_instance.bar (destroy)
|
||||||
|
aws_instance.bar (destroy) -> provider.aws
|
||||||
aws_instance.foo
|
aws_instance.foo
|
||||||
aws_instance.foo -> aws_instance.foo (destroy)
|
aws_instance.foo -> aws_instance.foo (destroy)
|
||||||
|
aws_instance.foo -> provider.aws
|
||||||
aws_instance.foo (destroy)
|
aws_instance.foo (destroy)
|
||||||
aws_instance.foo (destroy) -> aws_instance.bar (destroy)
|
aws_instance.foo (destroy) -> aws_instance.bar (destroy)
|
||||||
|
aws_instance.foo (destroy) -> provider.aws
|
||||||
|
provider.aws
|
||||||
root
|
root
|
||||||
root -> aws_instance.bar
|
root -> aws_instance.bar
|
||||||
root -> aws_instance.foo
|
root -> aws_instance.foo
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
provider "aws" {}
|
||||||
|
|
||||||
resource "aws_instance" "foo" {
|
resource "aws_instance" "foo" {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue