func (a InstanceProfilesAPI) Synchronized(arn string, testCallback func() bool) {
	timeout := 30 * time.Minute
	err := resource.RetryContext(a.context, timeout,
		func() *resource.RetryError {
			list, err := a.List()
			if err != nil {
				return resource.NonRetryableError(err)
			}
			currentTest := common.Current.GetOrUnknown(a.context)
			for _, ip := range list {
				if ip.InstanceProfileArn == arn {
					log.Printf("[INFO] %s: Waiting to acquire instance profile", currentTest)
					return resource.RetryableError(fmt.Errorf(
						"%s is registered, waiting to release", arn))
				}
			}
			cbError := resource.RetryContext(a.context, timeout, func() *resource.RetryError {
				if a.IsRegistered(arn) {
					log.Printf("[INFO] %s: Waiting to acquire instance profile", currentTest)
					return resource.RetryableError(fmt.Errorf("%s: Waiting to acquire", currentTest))
				}
				if !testCallback() {
					log.Printf("[INFO] %s: Callback returned false", currentTest)
					return resource.RetryableError(fmt.Errorf("%s: Callback returned false", currentTest))
				}
				log.Printf("[INFO] %s: Successfully tested instance profile", currentTest)
				if _, err = a.Read(arn); err == nil {
					log.Printf("[INFO] %s: Didn't release instance profile", currentTest)
				}
				return nil
			})
			if cbError != nil {
				return resource.RetryableError(cbError)
			}
			return nil
		})
	if err != nil {
		panic(err)
	}
}
Synchronized test helper for working with only single instance profile
package identity
import (
	"context"
	"fmt"
	"log"
	"net/http"
	"strings"
	"time"
	"github.com/databrickslabs/terraform-provider-databricks/common"
	"github.com/hashicorp/go-cty/cty"
	"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
type InstanceProfileInfo struct {
	InstanceProfileArn    string `json:"instance_profile_arn,omitempty"`
	IsMetaInstanceProfile bool   `json:"is_meta_instance_profile,omitempty"`
	SkipValidation        bool   `json:"skip_validation,omitempty" tf:"computed"`
}
type InstanceProfileList struct {
	InstanceProfiles []InstanceProfileInfo `json:"instance_profiles,omitempty"`
}
func NewInstanceProfilesAPI(ctx context.Context, m interface{}) InstanceProfilesAPI {
	return InstanceProfilesAPI{
		client:  m.(*common.DatabricksClient),
		context: ctx,
	}
}
type InstanceProfilesAPI struct {
	client  *common.DatabricksClient
	context context.Context
}
func (a InstanceProfilesAPI) Create(ipi InstanceProfileInfo) error {
	return a.client.Post(a.context, "/instance-profiles/add", ipi, nil)
}
func (a InstanceProfilesAPI) Read(instanceProfileARN string) (result InstanceProfileInfo, err error) {
	instanceProfiles, err := a.List()
	if err != nil {
		return
	}
	for _, profile := range instanceProfiles {
		if profile.InstanceProfileArn == instanceProfileARN {
			result = profile
			return
		}
	}
	err = common.APIError{
		ErrorCode: "NOT_FOUND",
		Message: fmt.Sprintf("Instance profile with name: %s not found in "+
			"list of instance profiles in the workspace!", instanceProfileARN),
		Resource:   "/api/2.0/instance-profiles/list",
		StatusCode: http.StatusNotFound,
	}
	return
}
func (a InstanceProfilesAPI) List() ([]InstanceProfileInfo, error) {
	var instanceProfilesArnList InstanceProfileList
	err := a.client.Get(a.context, "/instance-profiles/list", nil, &instanceProfilesArnList)
	return instanceProfilesArnList.InstanceProfiles, err
}
func (a InstanceProfilesAPI) Delete(instanceProfileARN string) error {
	return a.client.Post(a.context, "/instance-profiles/remove", map[string]interface{}{
		"instance_profile_arn": instanceProfileARN,
	}, nil)
}
func (a InstanceProfilesAPI) IsRegistered(arn string) bool {
	if _, err := a.Read(arn); err == nil {
		return true
	}
	return false
}