// SetResourceInstanceDeposed saves the given instance object as a deposed
// generation of the resource instance with the given address and deposed key.
//
// Call this method only for pre-existing deposed objects that already have
// a known DeposedKey. For example, this method is useful if reloading objects
// that were persisted to a state file. To mark the current object as deposed,
// use DeposeResourceInstanceObject instead.
//
// The resource that contains the given instance must already exist in the
// state, or this method will panic. Use Resource to check first if its
// presence is not already guaranteed.
//
// Any existing current instance object for the given resource and deposed key
// is overwritten. Set obj to nil to remove the deposed object altogether. If
// the instance is left with no objects after this operation then it will
// be removed from its containing resource altogether.
SetResourceInstanceDeposed saves the given instance object as a deposed
generation of the resource instance with the given address and deposed key.

Call this method only for pre-existing deposed objects that already have
a known DeposedKey. For example, this method is useful if reloading objects
that were persisted to a state file. To mark the current object as deposed,
use DeposeResourceInstanceObject instead.

The resource that contains the given instance must already exist in the
state, or this method will panic. Use Resource to check first if its
presence is not already guaranteed.

Any existing current instance object for the given resource and deposed key
is overwritten. Set obj to nil to remove the deposed object altogether. If
the instance is left with no objects after this operation then it will
be removed from its containing resource altogether.
// SetResourceInstanceDeposed saves the given instance object as a deposed // generation of the resource instance with the given address and deposed key . // // Call this method only for pre - existing deposed objects that already have // a known DeposedKey . For example this method is useful if reloading objects // that were persisted to a state file . To mark the current object as deposed // use DeposeResourceInstanceObject instead . // // The resource that contains the given instance must already exist in the // state or this method will panic . Use Resource to check first if its // presence is not already guaranteed . // // Any existing current instance object for the given resource and deposed key // is overwritten . Set obj to nil to remove the deposed object altogether . If // the instance is left with no objects after this operation then it will // be removed from its containing resource altogether .
func (ms *Module) SetResourceInstanceDeposed(addr addrs.ResourceInstance, key DeposedKey, obj *ResourceInstanceObjectSrc, provider addrs.AbsProviderConfig) {
	ms.SetResourceProvider(addr.Resource, provider)
	rs := ms.Resource(addr.Resource)
	is := rs.EnsureInstance(addr.Key)
	if obj != nil {
		is.Deposed[key] = obj
	} else {
		delete(is.Deposed, key)
	}
	if !is.HasObjects() {
		delete(rs.Instances, addr.Key)
	}
	if len(rs.Instances) == 0 {
		delete(ms.Resources, addr.Resource.String())
	}
}
func ( ms * Module ) SetResourceInstanceDeposed ( addr addrs . ResourceInstance , key DeposedKey , obj * ResourceInstanceObjectSrc , provider addrs . AbsProviderConfig ) { ms . SetResourceProvider ( addr . Resource , provider ) rs := ms . Resource ( addr . Resource ) is := rs . EnsureInstance ( addr . Key ) if obj != nil { is . Deposed [ key ] = obj } else { delete ( is . Deposed , key ) } if ! is . HasObjects ( ) { delete ( rs . Instances , addr . Key ) } if len ( rs . Instances ) == 0 { delete ( ms . Resources , addr . Resource . String ( ) ) } }
SetResourceInstanceDeposed saves the given instance object as a deposed
generation of the resource instance with the given address and deposed key.
SetResourceInstanceDeposed saves the given instance object as a deposed generation of the resource instance with the given address and deposed key .
// If we have no objects at all then we'll clean up. // Also clean up if we only expect to have one instance anyway // and there are none. We leave the resource behind if an each mode // is active because an empty list or map of instances is a valid state.