cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

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

AW
New Contributor III

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?

1 ACCEPTED SOLUTION

Accepted Solutions

Pat
Honored Contributor III

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

4 REPLIES 4

Pat
Honored Contributor III

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.

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
New Contributor III

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

Kaniz
Community Manager
Community Manager

Hi @Adrian Wyss​​, It would mean a lot if you could select the "Best Answer" to help others find the correct answer faster.

This makes that answer appear right after the question, so it's easier to find within a thread.

It also helps us mark the question as answered so we can have more eyes helping others with unanswered questions.

Can I count on you?

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.