code: func evaluateResourceCountExpression(expr hcl.Expression, ctx EvalContext) (int, tfdiags.Diagnostics) {
  	count, known, diags := evaluateResourceCountExpressionKnown(expr, ctx)
  	if !known {
  		// Currently this is a rather bad outcome from a UX standpoint, since we have
  		// no real mechanism to deal with this situation and all we can do is produce
  		// an error message.
  		// FIXME: In future, implement a built-in mechanism for deferring changes that
  		// can't yet be predicted, and use it to guide the user through several
  		// plan/apply steps until the desired configuration is eventually reached.
  		diags = diags.Append(&hcl.Diagnostic{
  			Severity: hcl.DiagError,
  			Summary:  "Invalid count argument",
  			Detail:   `The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target argument to first apply only the resources that the count depends on.`,
  			Subject:  expr.Range().Ptr(),
  		})
  	}
  	return count, diags
  }
docs: // evaluateResourceCountExpression is our standard mechanism for interpreting an
  // expression given for a "count" argument on a resource. This should be called
  // from the DynamicExpand of a node representing a resource in order to
  // determine the final count value.
  //
  // If the result is zero or positive and no error diagnostics are returned, then
  // the result is the literal count value to use.
  //
  // If the result is -1, this indicates that the given expression is nil and so
  // the "count" behavior should not be enabled for this resource at all.
  //
  // If error diagnostics are returned then the result is always the meaningless
  // placeholder value -1.