Accessing Resource object from within an attribute plan modifier

I’m writing a resource in a Terraform provider using the terraform-plugin-framework which has several attributes that interact in complex ways. One attribute is required, and if it’s known during planning it can be used to query the API to show the user the planned default value of another attribute that’s optional, as shown:

resource "example" "example" {
  required_attribute = "known value"
}

# example.example will be created
+ resource "example" "example" {
    + required_attribute = "known value"
    + optional_attribute = "default"
  }

If required_attribute is unknown during planning, then optional_attribute will also be unknown.

Currently, I’m implementing this by writing a resource plan modifier, because in my real provider optional_attribute is a much more complex nested object type whose own attributes have plan modifiers of their own, and since attribute plan modifiers run before resource plan modifiers, I end up having to write a lot of logic in the ModifyPlan() function to get the desired result.

I would strongly prefer to implement this using an attribute plan modifier that’s defined on optional_attribute, since it would completely save me from needing to convert/traverse/reconvert the entire data structure in ModifyPlan() and I could just use regular schema-defined attribute plan modifiers instead, since an attribute’s plan modifiers are run before any of its nested attributes’ plan modifiers. However, this would require access to the resource.Resource instance so that I can use its API client instance that was configured during Resource.Configure(), and the planmodifier.*Request types don’t provide any way to access it.

On the other hand, in my real provider, there are several other attributes whose planned values may also depend on required_attribute, and I would prefer to only make one API call to get all of their default values at once, as I’m currently doing with my resource plan modifier, rather than one API call per attribute, as would be necessary if I found a way to use an attribute plan modifier, unless I had some way to cache the API call result across attribute plan modifiers.

Is there some way to reference the Resource instance from an attribute plan modifier? I’ve tried implementing a plan modifier that takes a Resource instance as an argument (or takes a func that closes over it) and later uses it during PlanModify(), but the plan modifier is defined in the Schema() function, and the resource instance seems to be a nil pointer at that stage in the lifecycle.

Alternatively, if I could force my resource plan modifier to run before all of the attribute plan modifiers (or, equivalently, force specific attribute plan modifiers to run after the resource plan modifier), that would greatly simplify my implementation.