code: func (b *Remote) StateMgr(name string) (state.State, error) {
  	if b.workspace == "" && name == backend.DefaultStateName {
  		return nil, backend.ErrDefaultWorkspaceNotSupported
  	}
  	if b.prefix == "" && name != backend.DefaultStateName {
  		return nil, backend.ErrWorkspacesNotSupported
  	}
  
  	// Configure the remote workspace name.
  	switch {
  	case name == backend.DefaultStateName:
  		name = b.workspace
  	case b.prefix != "" && !strings.HasPrefix(name, b.prefix):
  		name = b.prefix + name
  	}
  
  	workspace, err := b.client.Workspaces.Read(context.Background(), b.organization, name)
  	if err != nil && err != tfe.ErrResourceNotFound {
  		return nil, fmt.Errorf("Failed to retrieve workspace %s: %v", name, err)
  	}
  
  	if err == tfe.ErrResourceNotFound {
  		options := tfe.WorkspaceCreateOptions{
  			Name: tfe.String(name),
  		}
  
  		// We only set the Terraform Version for the new workspace if this is
  		// a release candidate or a final release.
  		if tfversion.Prerelease == "" || strings.HasPrefix(tfversion.Prerelease, "rc") {
  			options.TerraformVersion = tfe.String(tfversion.String())
  		}
  
  		workspace, err = b.client.Workspaces.Create(context.Background(), b.organization, options)
  		if err != nil {
  			return nil, fmt.Errorf("Error creating workspace %s: %v", name, err)
  		}
  	}
  
  	client := &remoteClient{
  		client:       b.client,
  		organization: b.organization,
  		workspace:    workspace,
  
  		// This is optionally set during Terraform Enterprise runs.
  		runID: os.Getenv("TFE_RUN_ID"),
  	}
  
  	return &remote.State{Client: client}, nil
  }
docs: // StateMgr implements backend.Enhanced.