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:
parent
7b2f66c403
commit
2ea921f915
|
@ -53,22 +53,24 @@ func (n *NodeDestroyResourceInstance) DestroyAddr() *addrs.AbsResourceInstance {
|
|||
|
||||
// GraphNodeDestroyerCBD
|
||||
func (n *NodeDestroyResourceInstance) CreateBeforeDestroy() bool {
|
||||
if n.CreateBeforeDestroyOverride != nil {
|
||||
return *n.CreateBeforeDestroyOverride
|
||||
}
|
||||
|
||||
// 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
|
||||
// State takes precedence during destroy.
|
||||
// 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.
|
||||
if s := n.instanceState; s != nil {
|
||||
if s.Current != nil {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue