code: func (rs *Resource) EnsureInstance(key addrs.InstanceKey) *ResourceInstance {
  	ret := rs.Instance(key)
  	if ret == nil {
  		ret = NewResourceInstance()
  		rs.Instances[key] = ret
  	}
  	return ret
  }
docs: // EnsureInstance returns the state for the instance with the given key,
  // creating a new empty state for it if one doesn't already exist.
  //
  // Because this may create and save a new state, it is considered to be
  // a write operation.