diff --git a/states/instance_object.go b/states/instance_object.go index 9335b6977..d1b53e292 100644 --- a/states/instance_object.go +++ b/states/instance_object.go @@ -42,11 +42,6 @@ type ResourceInstanceObject struct { // 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. - DependsOn []addrs.Referenceable } // ObjectStatus represents the status of a RemoteObject. diff --git a/states/instance_object_src.go b/states/instance_object_src.go index c8f92bd0e..bf790db04 100644 --- a/states/instance_object_src.go +++ b/states/instance_object_src.go @@ -55,8 +55,6 @@ type ResourceInstanceObjectSrc struct { Status ObjectStatus Dependencies []addrs.ConfigResource CreateBeforeDestroy bool - // deprecated - DependsOn []addrs.Referenceable } // Decode unmarshals the raw representation of the object attributes. Pass the @@ -89,7 +87,6 @@ func (os *ResourceInstanceObjectSrc) Decode(ty cty.Type) (*ResourceInstanceObjec 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 5cd7708e1..f6a3919c3 100644 --- a/states/state_deepcopy.go +++ b/states/state_deepcopy.go @@ -158,12 +158,6 @@ func (obj *ResourceInstanceObjectSrc) DeepCopy() *ResourceInstanceObjectSrc { copy(dependencies, obj.Dependencies) } - var dependsOn []addrs.Referenceable - if obj.DependsOn != nil { - dependsOn = make([]addrs.Referenceable, len(obj.DependsOn)) - copy(dependsOn, obj.DependsOn) - } - return &ResourceInstanceObjectSrc{ Status: obj.Status, SchemaVersion: obj.SchemaVersion, @@ -171,7 +165,6 @@ func (obj *ResourceInstanceObjectSrc) DeepCopy() *ResourceInstanceObjectSrc { AttrsFlat: attrsFlat, AttrsJSON: attrsJSON, Dependencies: dependencies, - DependsOn: dependsOn, CreateBeforeDestroy: obj.CreateBeforeDestroy, } } diff --git a/states/statefile/testdata/roundtrip/v4-cbd.in.tfstate b/states/statefile/testdata/roundtrip/v4-cbd.in.tfstate new file mode 100644 index 000000000..35186cdd2 --- /dev/null +++ b/states/statefile/testdata/roundtrip/v4-cbd.in.tfstate @@ -0,0 +1,34 @@ +{ + "version": 4, + "serial": 0, + "lineage": "f2968801-fa14-41ab-a044-224f3a4adf04", + "terraform_version": "0.12.0", + "outputs": { + "numbers": { + "type": "string", + "value": "0,1" + } + }, + "resources": [ + { + "module": "module.modA", + "mode": "managed", + "type": "null_resource", + "name": "resource", + "provider": "provider[\"registry.terraform.io/-/null\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "id": "4639265839606265182", + "triggers": { + "input": "test" + } + }, + "create_before_destroy": true, + "private": "bnVsbA==" + } + ] + } + ] +} diff --git a/states/statefile/testdata/roundtrip/v4-cbd.out.tfstate b/states/statefile/testdata/roundtrip/v4-cbd.out.tfstate new file mode 120000 index 000000000..3831d381a --- /dev/null +++ b/states/statefile/testdata/roundtrip/v4-cbd.out.tfstate @@ -0,0 +1 @@ +v4-cbd.in.tfstate \ No newline at end of file diff --git a/states/statefile/version3_upgrade.go b/states/statefile/version3_upgrade.go index 0b97da080..e54a08ccd 100644 --- a/states/statefile/version3_upgrade.go +++ b/states/statefile/version3_upgrade.go @@ -370,7 +370,6 @@ func upgradeInstanceObjectV3ToV4(rsOld *resourceStateV2, isOld *instanceStateV2, Status: status, Deposed: string(deposedKey), AttributesFlat: attributes, - DependsOn: dependencies, SchemaVersion: schemaVersion, PrivateRaw: privateJSON, }, nil diff --git a/states/statefile/version4.go b/states/statefile/version4.go index 865e8f818..ca24cbb72 100644 --- a/states/statefile/version4.go +++ b/states/statefile/version4.go @@ -172,34 +172,6 @@ func prepareStateV4(sV4 *stateV4) (*File, tfdiags.Diagnostics) { obj.Private = raw } - { - // Allow both the deprecated `depends_on` and new - // `dependencies` to coexist for now so resources can be - // upgraded as they are refreshed. - depsRaw := isV4.DependsOn - deps := make([]addrs.Referenceable, 0, len(depsRaw)) - for _, depRaw := range depsRaw { - ref, refDiags := addrs.ParseRefStr(depRaw) - diags = diags.Append(refDiags) - if refDiags.HasErrors() { - continue - } - if len(ref.Remaining) != 0 { - diags = diags.Append(tfdiags.Sourceless( - tfdiags.Error, - "Invalid resource instance metadata in state", - fmt.Sprintf("Instance %s declares dependency on %q, which is not a reference to a dependable object.", instAddr.Absolute(moduleAddr), depRaw), - )) - } - if ref.Subject == nil { - // Should never happen - panic(fmt.Sprintf("parsing dependency %q for instance %s returned a nil address", depRaw, instAddr.Absolute(moduleAddr))) - } - deps = append(deps, ref.Subject) - } - obj.DependsOn = deps - } - { depsRaw := isV4.Dependencies deps := make([]addrs.ConfigResource, 0, len(depsRaw)) @@ -463,11 +435,6 @@ func appendInstanceObjectStateV4(rs *states.Resource, is *states.ResourceInstanc deps[i] = depAddr.String() } - depOn := make([]string, len(obj.DependsOn)) - for i, depAddr := range obj.DependsOn { - depOn[i] = depAddr.String() - } - var rawKey interface{} switch tk := key.(type) { case addrs.IntKey: @@ -493,7 +460,6 @@ func appendInstanceObjectStateV4(rs *states.Resource, is *states.ResourceInstanc AttributesRaw: obj.AttrsJSON, PrivateRaw: privateRaw, Dependencies: deps, - DependsOn: depOn, CreateBeforeDestroy: obj.CreateBeforeDestroy, }), diags } @@ -545,7 +511,6 @@ type instanceObjectStateV4 struct { PrivateRaw []byte `json:"private,omitempty"` Dependencies []string `json:"dependencies,omitempty"` - DependsOn []string `json:"depends_on,omitempty"` CreateBeforeDestroy bool `json:"create_before_destroy"` }