<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Terraform - Create SVC Principal under account and assign some objects to the SVC Principal in Data Governance</title>
    <link>https://community.databricks.com/t5/data-governance/terraform-create-svc-principal-under-account-and-assign-some/m-p/26040#M823</link>
    <description>&lt;P&gt;Hi, We have some problems to create some resources using terraform, after the Unity catalog migration. We have created a group and SVC Principal under account as in the doc using terraform. (AWS infrastructure) (&lt;A href="https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/group" alt="https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/group" target="_blank"&gt;https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/group&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;resource "databricks_group" "group_account_level" {
  display_name               = "databricks_deployments"
  allow_cluster_create       = true
  allow_instance_pool_create = true
  workspace_access           = true
&amp;nbsp;
  provider = databricks.account_level
}
&amp;nbsp;
resource "databricks_service_principal" "spark_account_level" {
  display_name = "SVC_SPARK"
  provider     = databricks.account_level
}
&amp;nbsp;
resource "databricks_group_member" "spark_deployments" {
  group_id  = databricks_group.group_account_level.id
  member_id = databricks_service_principal.spark_account_level.id
&amp;nbsp;
  provider = databricks.account_level
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The provider uses the databricks host as in the documentation. (&lt;A href="https://accounts.cloud.databricks.com" alt="https://accounts.cloud.databricks.com" target="_blank"&gt;https://accounts.cloud.databricks.com&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We need to use the SVC Principal with the following resources:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;databricks_permissions (authorization token, permission_level = "CAN_USE")&lt;/LI&gt;&lt;LI&gt;databricks_group_role (to assign an instance profile that exists and workspace level)&lt;/LI&gt;&lt;LI&gt;databricks_secret_acl (some secrets that were present before the unity catalog migration)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All failed I tried the following combinations:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;. Using the databricks provider used to create the service principal at account level: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;resource "databricks_group_role" "instance_profile_group_deployments" {
  group_id = databricks_group.group_account_level.id
  role     = databricks_instance_profile.ds.id
&amp;nbsp;
  provider = databricks.account_level
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Looks like the API is not defined under account level&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;. Using the provider under workspace&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;resource "databricks_group_role" "instance_profile_group_deployments" {
  group_id = databricks_group.group_account_level.id
  role     = databricks_instance_profile.ds.id
&amp;nbsp;
  provider = databricks.workspace_url
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;then it complains can not find the group with the id XXXX, however the group exists but under account level&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help will be appreciated&lt;/P&gt;</description>
    <pubDate>Mon, 24 Oct 2022 17:03:38 GMT</pubDate>
    <dc:creator>jcasanella</dc:creator>
    <dc:date>2022-10-24T17:03:38Z</dc:date>
    <item>
      <title>Terraform - Create SVC Principal under account and assign some objects to the SVC Principal</title>
      <link>https://community.databricks.com/t5/data-governance/terraform-create-svc-principal-under-account-and-assign-some/m-p/26040#M823</link>
      <description>&lt;P&gt;Hi, We have some problems to create some resources using terraform, after the Unity catalog migration. We have created a group and SVC Principal under account as in the doc using terraform. (AWS infrastructure) (&lt;A href="https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/group" alt="https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/group" target="_blank"&gt;https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/group&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;resource "databricks_group" "group_account_level" {
  display_name               = "databricks_deployments"
  allow_cluster_create       = true
  allow_instance_pool_create = true
  workspace_access           = true
&amp;nbsp;
  provider = databricks.account_level
}
&amp;nbsp;
resource "databricks_service_principal" "spark_account_level" {
  display_name = "SVC_SPARK"
  provider     = databricks.account_level
}
&amp;nbsp;
resource "databricks_group_member" "spark_deployments" {
  group_id  = databricks_group.group_account_level.id
  member_id = databricks_service_principal.spark_account_level.id
&amp;nbsp;
  provider = databricks.account_level
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The provider uses the databricks host as in the documentation. (&lt;A href="https://accounts.cloud.databricks.com" alt="https://accounts.cloud.databricks.com" target="_blank"&gt;https://accounts.cloud.databricks.com&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We need to use the SVC Principal with the following resources:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;databricks_permissions (authorization token, permission_level = "CAN_USE")&lt;/LI&gt;&lt;LI&gt;databricks_group_role (to assign an instance profile that exists and workspace level)&lt;/LI&gt;&lt;LI&gt;databricks_secret_acl (some secrets that were present before the unity catalog migration)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All failed I tried the following combinations:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;. Using the databricks provider used to create the service principal at account level: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;resource "databricks_group_role" "instance_profile_group_deployments" {
  group_id = databricks_group.group_account_level.id
  role     = databricks_instance_profile.ds.id
&amp;nbsp;
  provider = databricks.account_level
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Looks like the API is not defined under account level&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;. Using the provider under workspace&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;resource "databricks_group_role" "instance_profile_group_deployments" {
  group_id = databricks_group.group_account_level.id
  role     = databricks_instance_profile.ds.id
&amp;nbsp;
  provider = databricks.workspace_url
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;then it complains can not find the group with the id XXXX, however the group exists but under account level&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help will be appreciated&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 17:03:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/terraform-create-svc-principal-under-account-and-assign-some/m-p/26040#M823</guid>
      <dc:creator>jcasanella</dc:creator>
      <dc:date>2022-10-24T17:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Terraform - Create SVC Principal under account and assign some objects to the SVC Principal</title>
      <link>https://community.databricks.com/t5/data-governance/terraform-create-svc-principal-under-account-and-assign-some/m-p/26041#M824</link>
      <description>&lt;P&gt;do we need to create under account and workspace?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 12:32:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/terraform-create-svc-principal-under-account-and-assign-some/m-p/26041#M824</guid>
      <dc:creator>jcasanella</dc:creator>
      <dc:date>2022-10-25T12:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: Terraform - Create SVC Principal under account and assign some objects to the SVC Principal</title>
      <link>https://community.databricks.com/t5/data-governance/terraform-create-svc-principal-under-account-and-assign-some/m-p/26042#M825</link>
      <description>&lt;P&gt;Hi @Jordi Casanella​&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I have been working with terraform for databricks lately and I would say that I had to switch my approach couple of times due to issues like you have right now (account vs workspace level API).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume that with this part you didn't have issues and you were able to:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;create group&lt;/LI&gt;&lt;LI&gt;create SP&lt;/LI&gt;&lt;LI&gt;add SP to the group&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE&gt;resource "databricks_group" "group_account_level" {
      display_name               = "databricks_deployments"
      allow_cluster_create       = true
      allow_instance_pool_create = true
      workspace_access           = true
     
      provider = databricks.account_level
    }
     
    resource "databricks_service_principal" "spark_account_level" {
      display_name = "SVC_SPARK"
      provider     = databricks.account_level
    }
     
    resource "databricks_group_member" "spark_deployments" {
      group_id  = databricks_group.group_account_level.id
      member_id = databricks_service_principal.spark_account_level.id
     
      provider = databricks.account_level
    }&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to be able to use the SP on the workspace level, as you have mentioned:&lt;/P&gt;&lt;P&gt;databricks_permissions, databricks_group_role, databrics_secret_acl you need to assign the group to the workspace, you can achieve this using `mws_permission_assignment`:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;resource "databricks_mws_permission_assignment" "ws_access" {
  provider     = databricks.account_level
  workspace_id = &amp;lt;YOUR_WORKSPACE_ID&amp;gt;
  principal_id = databricks_group.group_account_level.id
  permissions  = ["USER"]
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;A href="https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/mws_permission_assignment" alt="https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/mws_permission_assignment" target="_blank"&gt;https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/mws_permission_assignment&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then you can use that group in you workspace:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;resource "databricks_permissions" "this" {
  provider      = databricks.workspace
  authorization = "tokens"
  access_control {
    group_name       = databricks_group.group_account_level.display_name
    permission_level = "CAN_USE"
  }
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;Pat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 09:40:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/terraform-create-svc-principal-under-account-and-assign-some/m-p/26042#M825</guid>
      <dc:creator>Pat</dc:creator>
      <dc:date>2022-11-01T09:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: Terraform - Create SVC Principal under account and assign some objects to the SVC Principal</title>
      <link>https://community.databricks.com/t5/data-governance/terraform-create-svc-principal-under-account-and-assign-some/m-p/26043#M826</link>
      <description>&lt;P&gt;@Pat Sienkiewicz​&amp;nbsp;After check the terraform github implementation and the API, I found what u did a couple of days ago:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://api-docs.databricks.com/rest/latest/permission-assignment-account-api.html?_ga=2.84586331.316392714.1666604073-1391049329.1664921700&amp;amp;_gac=1.185916891.1665591220.Cj0KCQjwy5maBhDdARIsAMxrkw1GNKcb_8_CSIQXPsP3pBH9JLEcV8cZoW27UAh_y70uJ4tMHdtHsr4aAlMYEALw_wcB" target="test_blank"&gt;https://api-docs.databricks.com/rest/latest/permission-assignment-account-api.html?_ga=2.84586331.316392714.1666604073-1391049329.1664921700&amp;amp;_gac=1.185916891.1665591220.Cj0KCQjwy5maBhDdARIsAMxrkw1GNKcb_8_CSIQXPsP3pBH9JLEcV8cZoW27UAh_y70uJ4tMHdtHsr4aAlMYEALw_wcB&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just adding here the API doc in case can help someone else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So thanks a lot, you're awesome. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 12:34:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/terraform-create-svc-principal-under-account-and-assign-some/m-p/26043#M826</guid>
      <dc:creator>jcasanella</dc:creator>
      <dc:date>2022-11-03T12:34:23Z</dc:date>
    </item>
  </channel>
</rss>

