destroy nodes must rely on the state cbd status

When there is only a destroy node, there is no descendent to check for
"forced CBD", so we can only rely on the state to verify.
This commit is contained in:
James Bardin 2020-09-16 09:52:48 -04:00
parent 7b2f66c403
commit 2ea921f915
1 changed files with 12 additions and 10 deletions

View File

@ -53,22 +53,24 @@ func (n *NodeDestroyResourceInstance) DestroyAddr() *addrs.AbsResourceInstance {
// GraphNodeDestroyerCBD // GraphNodeDestroyerCBD
func (n *NodeDestroyResourceInstance) CreateBeforeDestroy() bool { func (n *NodeDestroyResourceInstance) CreateBeforeDestroy() bool {
if n.CreateBeforeDestroyOverride != nil { // State takes precedence during destroy.
return *n.CreateBeforeDestroyOverride // If the resource was removed, there is no config to check.
} // If CBD was forced from descendent, it should be saved in the state
// already.
// Config takes precedence
if n.Config != nil && n.Config.Managed != nil {
return n.Config.Managed.CreateBeforeDestroy
}
// Otherwise check the state for a stored destroy order
if s := n.instanceState; s != nil { if s := n.instanceState; s != nil {
if s.Current != nil { if s.Current != nil {
return s.Current.CreateBeforeDestroy return s.Current.CreateBeforeDestroy
} }
} }
if n.CreateBeforeDestroyOverride != nil {
return *n.CreateBeforeDestroyOverride
}
if n.Config != nil && n.Config.Managed != nil {
return n.Config.Managed.CreateBeforeDestroy
}
return false return false
} }