func evaluateResourceForEachExpression(expr hcl.Expression, ctx EvalContext) (forEach map[string]cty.Value, diags tfdiags.Diagnostics) {
	forEachMap, known, diags := evaluateResourceForEachExpressionKnown(expr, ctx)
	if !known {
		diags = diags.Append(&hcl.Diagnostic{
			Severity: hcl.DiagError,
			Summary:  "Invalid forEach argument",
			Detail:   `The "for_each" 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 for_each depends on.`,
			Subject:  expr.Range().Ptr(),
		})
	}
	return forEachMap, diags
}
evaluateResourceForEachExpression interprets a "for_each" argument on a resource.

Returns a cty.Value map, and diagnostics if necessary. It will return nil if
the expression is nil, and is used to distinguish between an unset for_each and an
empty map
package terraform
import (
	"fmt"
	"github.com/hashicorp/hcl2/hcl"
	"github.com/hashicorp/terraform-plugin-sdk/internal/tfdiags"
	"github.com/zclconf/go-cty/cty"
)