cancel
Showing results for 
Search instead for 
Did you mean: 
Community Platform Discussions
Connect with fellow community members to discuss general topics related to the Databricks platform, industry trends, and best practices. Share experiences, ask questions, and foster collaboration within the community.
cancel
Showing results for 
Search instead for 
Did you mean: 

Associating a Git Credential with a Service Principal using Terraform Provider (AWS)

Kinger
New Contributor

I am attempting to create a Databrick Repo in a workspace via Terraform. I would like the Repo and the associated Git Credential to be associated with a Service Principal. 

In my initial run, the Terraform provider is associated with the user defined in the .databrickscfg file and when resources were created, the user had a link to the created Git Credential. This causes issues if that particular user already had a git credential (since there can only be 1 git credential associated with a user).

To avoid the Git Credential getting associated with the user, I would like to

- Create a Service Principal

- Create a git credential associated with that Service Provider

- Have the repo creation be done using that git credential. Basically, create the repo using the created Service Principal

I have not found a way to get the git credential associated with the SP and associate the SP with the Repo creation in terraform. I have seen some threads saying you can associate an SP for repo creation but they seem to be on Azure or just via the CLI? Can this be done in the databricks terraform provider?

Thank you.

2 REPLIES 2

Kaniz_Fatma
Community Manager
Community Manager

Hi @KingerThe Databricks Terraform provider does not support creating a git credential associated with a Service Principal (SP) and associating the SP with the Repo creation.
• However, you can create a Service Principal and associate it with a git credential using Databricks APIs.
• This process cannot be performed via the user interface and requires tools like curl, Postman, or Terraform to call the APIs.
• The general process involves creating a Service Principal using the Service Principals API and adding Git provider credentials to the workspace using the Git Credentials API.
• After creating and associating the Service Principal with the git credential, it can be used for repo creation and other operations.
• The user token in the .databrickscfg file should be replaced with the token of the Service Principal when performing operations as the Service Principal.

Hello, could you attach any reference post/article around this? I'm also trying to associate an SP with a Git Credential, so that I can set the SP as "run_as" in the Databricks Job config. I have AWS as the cloud.

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