cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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_Fatma
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?

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group