diff --git a/states/instance_object.go b/states/instance_object.go index 78e1dda93..1642b4569 100644 --- a/states/instance_object.go +++ b/states/instance_object.go @@ -36,6 +36,13 @@ type ResourceInstanceObject struct { // altogether, or is now deposed. Dependencies []addrs.AbsResource + // CreateBeforeDestroy reflects the status of the lifecycle + // create_before_destroy option when this instance was last updated. + // Because create_before_destroy also effects the overall ordering of the + // destroy operations, we need to record the status to ensure a resource + // removed from the config will still be destroyed in the same manner. + CreateBeforeDestroy bool + // DependsOn corresponds to the deprecated `depends_on` field in the state. // This field contained the configuration `depends_on` values, and some of // the references from within a single module. diff --git a/states/instance_object_src.go b/states/instance_object_src.go index a18cf313c..ff56bcfb8 100644 --- a/states/instance_object_src.go +++ b/states/instance_object_src.go @@ -51,9 +51,10 @@ type ResourceInstanceObjectSrc struct { // These fields all correspond to the fields of the same name on // ResourceInstanceObject. - Private []byte - Status ObjectStatus - Dependencies []addrs.AbsResource + Private []byte + Status ObjectStatus + Dependencies []addrs.AbsResource + CreateBeforeDestroy bool // deprecated DependsOn []addrs.Referenceable } @@ -85,11 +86,12 @@ func (os *ResourceInstanceObjectSrc) Decode(ty cty.Type) (*ResourceInstanceObjec } return &ResourceInstanceObject{ - Value: val, - Status: os.Status, - Dependencies: os.Dependencies, - DependsOn: os.DependsOn, - Private: os.Private, + Value: val, + Status: os.Status, + Dependencies: os.Dependencies, + DependsOn: os.DependsOn, + Private: os.Private, + CreateBeforeDestroy: os.CreateBeforeDestroy, }, nil } diff --git a/states/state_deepcopy.go b/states/state_deepcopy.go index 7d7a7ef10..89082fb8e 100644 --- a/states/state_deepcopy.go +++ b/states/state_deepcopy.go @@ -166,13 +166,14 @@ func (obj *ResourceInstanceObjectSrc) DeepCopy() *ResourceInstanceObjectSrc { } return &ResourceInstanceObjectSrc{ - Status: obj.Status, - SchemaVersion: obj.SchemaVersion, - Private: private, - AttrsFlat: attrsFlat, - AttrsJSON: attrsJSON, - Dependencies: dependencies, - DependsOn: dependsOn, + Status: obj.Status, + SchemaVersion: obj.SchemaVersion, + Private: private, + AttrsFlat: attrsFlat, + AttrsJSON: attrsJSON, + Dependencies: dependencies, + DependsOn: dependsOn, + CreateBeforeDestroy: obj.CreateBeforeDestroy, } }