diff --git a/terraform/node_resource_destroy.go b/terraform/node_resource_destroy.go index 1df561b4a..27ee4ff2e 100644 --- a/terraform/node_resource_destroy.go +++ b/terraform/node_resource_destroy.go @@ -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 }