code: func (ms *Module) SetResourceInstanceDeposed(addr addrs.ResourceInstance, key DeposedKey, obj *ResourceInstanceObjectSrc, provider addrs.AbsProviderConfig) {
  	ms.SetResourceMeta(addr.Resource, eachModeForInstanceKey(addr.Key), 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() {
  		// If we have no objects at all then we'll clean up.
  		delete(rs.Instances, addr.Key)
  	}
  	if rs.EachMode == NoEach && len(rs.Instances) == 0 {
  		// 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.
  		delete(ms.Resources, addr.Resource.String())
  	}
  }
docs: // 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.