code: func (n *EvalWriteResourceState) Eval(ctx EvalContext) (interface{}, error) {
  	var diags tfdiags.Diagnostics
  	absAddr := n.Addr.Absolute(ctx.Path())
  	state := ctx.State()
  
  	count, countDiags := evaluateResourceCountExpression(n.Config.Count, ctx)
  	diags = diags.Append(countDiags)
  	if countDiags.HasErrors() {
  		return nil, diags.Err()
  	}
  
  	// Currently we ony support NoEach and EachList, because for_each support
  	// is not fully wired up across Terraform. Once for_each support is added,
  	// we'll need to handle that here too, setting states.EachMap if the
  	// assigned expression is a map.
  	eachMode := states.NoEach
  	if count >= 0 { // -1 signals "count not set"
  		eachMode = states.EachList
  	}
  
  	// This method takes care of all of the business logic of updating this
  	// while ensuring that any existing instances are preserved, etc.
  	state.SetResourceMeta(absAddr, eachMode, n.ProviderAddr)
  
  	return nil, nil
  }
docs: // TODO: test