databricks / terraform-provider-databricks

Databricks Terraform Provider
https://registry.terraform.io/providers/databricks/databricks/latest
Other
445 stars 384 forks source link

[FEATURE] Expose argument `workspace_id` in resource `databricks_permission_assignment` #2241

Open camilo-s opened 1 year ago

camilo-s commented 1 year ago

Use-cases

Here's a summary of my use-case (also described in #2239):

Attempted Solutions

My current solution proceeds as follows:

data "databricks_group" "users" {
  for_each = var.azure_ad_groups

  display_name = each.key

  provider = databricks.account
}

resource "databricks_permission_assignment" "users" {
  for_each = var.azure_ad_groups

  principal_id = data.databricks_group.users[each.key].id
  permissions  = ["USERS"]
}

Proposal

My proposals are:

  1. To enable this resource for use with an account provider, so it can talk to the Permission Assignment Account API, and correspondingly expose the workspace_id parameter of this API.

    resource "databricks_permission_assignment" "users" {
      for_each = var.azure_ad_groups
    
      principal_id = data.databricks_group.users[each.key].id
      permissions  = ["USERS"]
      workspace_id = var.databricks_workspace_id
    
      provider = databricks.account
    }
  2. To create an AzAPI-provider of sorts for Databricks, as a thin layer on top of the Databricks REST APIs to be able to interact with evolving APIs that are not yet properly incorporated in the Databricks provider.

References

camilo-s commented 1 year ago

Ideally this should follow the schema for databricks_mws_permission_assignment, which does have a workspace_id attribute.

nkvuong commented 1 year ago

@camilo-s it is a bit confusing, but databricks_mws_permission_assignment is meant to be used at account level, and databricks_permission_assignment is meant to be used at workspace level (and therefore does not require a workspace id)

camilo-s commented 1 year ago

@nkvuong I understand this. But then how might databricks_permission_assignment possibly be used to provision existing account-level groups at the workspace level at all? It acts at workspace level (i.e. calling the Permission Assignment Workspace API) which is agnostic to account-level groups, so it rightfully returns an error for not being able to find the account-level groups by ID, as I've indicated in #2239.

I made an attempt to leverage databricks_mws_permission_assignment to call the Permission Assignment Account API for my Azure Databricks account, but that API doesn't seem to work for Azure at the moment (documented in #2239).