Creating a service principal with admin role on account level in Azure Databricks using Terraform

AW
Databricks Partner

Dear Community,

In the GUI I can grant the admin role to a service principal with a simple switch.

switchHow can I achive the same in Terraform? Do you have some code examples?

Pat
Esteemed Contributor

Hi @Adrian Wyss​ ,

to create SP with `account admin` role, please use the following:

resource "databricks_service_principal" "this" {
  provider     = databricks.mws
  display_name = "some-name"
}
 
# assign account_admin role
resource "databricks_service_principal_role" "this" {
  provider             = databricks.mws
  service_principal_id = databricks_service_principal.this.id
  role                 = "account_admin"
}

thanks,

Pat.

View solution in original post

Hey @Pat,

unfortunately I get following error

 

Error: cannot read service principal role: Service Principal has no role

 

from Terraform resource "databricks_service_principal_role" when using your approach from above.

Do you have any idea?

AW
Databricks Partner

Dear @Pat Sienkiewicz​ , works perfectly! It would be so easy it the documentation would be better... Rg Adrian