<?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 Re: Error: cannot create metastore data access: No metastore assigned for the current workspace. in Data Governance</title>
    <link>https://community.databricks.com/t5/data-governance/error-cannot-create-metastore-data-access-no-metastore-assigned/m-p/30982#M892</link>
    <description>&lt;P&gt;Hi @Pat Sienkiewicz​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We'd love to hear from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Oct 2022 05:29:16 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-10-17T05:29:16Z</dc:date>
    <item>
      <title>Error: cannot create metastore data access: No metastore assigned for the current workspace.</title>
      <link>https://community.databricks.com/t5/data-governance/error-cannot-create-metastore-data-access-no-metastore-assigned/m-p/30979#M889</link>
      <description>&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":chicken:"&gt;🐔&lt;/span&gt;  and &lt;span class="lia-unicode-emoji" title=":hatching_chick:"&gt;🐣&lt;/span&gt;  situation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am currently trying to came up with the way how to deploy Databricks with Terraform in multi-region, multi-tenant environment. I am not talking about simple cases like this (https://docs.databricks.com/data-governance/unity-catalog/automate.html).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ideally I would like to have separate DEV UC and PROD UC at least, with multiple workspaces.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've created some modules for re-usable resources:&lt;/P&gt;&lt;P&gt;metastore(uc)&lt;/P&gt;&lt;P&gt;s3&lt;/P&gt;&lt;P&gt;vpc&lt;/P&gt;&lt;P&gt;workspace&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and I've planned my deployment this way:&lt;/P&gt;&lt;P&gt;datalake/dev_1&lt;/P&gt;&lt;P&gt;datalake/dev_2&lt;/P&gt;&lt;P&gt;datalake/prod_1&lt;/P&gt;&lt;P&gt;datalake/prod_2&lt;/P&gt;&lt;P&gt;datalake/global&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dev_* and prod_* -  different workspaces&lt;/P&gt;&lt;P&gt;global - metastore&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The idea was to create first Unity Catalog (metastore) then in each datalake/env_* workspace attach workspace to the Unity Catalog, but it looks like we can create the Unity Catalog without the workspace, but there is no way to assign metastore_data_access to the Unity Catalog without the workspace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Link to the example usage (https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/metastore_data_access#example-usage)&lt;/P&gt;&lt;P&gt;It seems like it should work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;## Create UC metastore
resource "databricks_metastore" "this" {
  provider      = databricks.workspace
  name          = "${local.prefix}-${var.workspace}-metastore-${var.region}-${var.env}"
  storage_root  = "s3://${var.aws_s3_bucket}/metastore"
  owner         = var.owner
  force_destroy = true
}
&amp;nbsp;
resource "databricks_metastore_data_access" "this" {
  provider     = databricks.workspace
  metastore_id = databricks_metastore.this.id
  name         = aws_iam_role.metastore_data_access.name
  aws_iam_role {
    role_arn = aws_iam_role.metastore_data_access.arn
  }
  is_default = true
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the Unity Catalog deployment blog (https://docs.databricks.com/data-governance/unity-catalog/automate.html#configure-a-metastore) you can see assignment of the ws to the metastore (or vice versa).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;resource "databricks_metastore_assignment" "default_metastore" {
  depends_on           = [ databricks_metastore_data_access.metastore_data_access ]
  workspace_id         = var.default_metastore_workspace_id
  metastore_id         = databricks_metastore.metastore.id
  default_catalog_name = var.default_metastore_default_catalog_name
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is actually done first, so I guess the steps should be changed for better visibility:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;variable "metastore_name" {}
variable "metastore_label" {}
variable "default_metastore_workspace_id" {}
variable "default_metastore_default_catalog_name" {}
&amp;nbsp;
resource "databricks_metastore" "metastore" {
  name          = var.metastore_name
  storage_root  = "s3://${aws_s3_bucket.metastore.id}/${var.metastore_label}"
  force_destroy = true
}
&amp;nbsp;
resource "databricks_metastore_assignment" "default_metastore" {
  depends_on           = [ databricks_metastore_data_access.metastore_data_access ]
  workspace_id         = var.default_metastore_workspace_id
  metastore_id         = databricks_metastore.metastore.id
  default_catalog_name = var.default_metastore_default_catalog_name
}
&amp;nbsp;
resource "databricks_metastore_data_access" "metastore_data_access" {
  depends_on   = [ databricks_metastore.metastore ]
  metastore_id = databricks_metastore.metastore.id
  name         = aws_iam_role.metastore_data_access.name
  aws_iam_role { role_arn = aws_iam_role.metastore_data_access.arn }
  is_default   = true
}
&amp;nbsp;
&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Let's get back to the question. How you are planning your terraform deployment with UC ? It would be great to learn how others are dealing with this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 2 things in my mind, &lt;/P&gt;&lt;UL&gt;&lt;LI&gt;have an admin workspace to deploy UC, but I guess I will need one per UC (so this is not going to work)&lt;/LI&gt;&lt;LI&gt;first deploy the workspace with Unity Catalog, then add other workspaces. I would need to create default workspace for example: &lt;UL&gt;&lt;LI&gt;dev_datalake ws with Unity Catalog then other workspaces dev_analytics, dev_sandbox, etc are going to be deployed different way. &lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This means that my `global` idea won't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking forward to see some ideas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 09:38:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/error-cannot-create-metastore-data-access-no-metastore-assigned/m-p/30979#M889</guid>
      <dc:creator>Pat</dc:creator>
      <dc:date>2022-09-23T09:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: Error: cannot create metastore data access: No metastore assigned for the current workspace.</title>
      <link>https://community.databricks.com/t5/data-governance/error-cannot-create-metastore-data-access-no-metastore-assigned/m-p/30980#M890</link>
      <description>&lt;P&gt;I got the same error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Error: cannot create metastore data access: No metastore assigned for the current workspace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and fixed it by reversing the depends_on order. I am now making databricks_metastore_data_access depend on databricks_metastore_assignment. Here is my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;resource "databricks_metastore" "this" {&lt;/P&gt;&lt;P&gt;&amp;nbsp;provider&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= databricks.workspace&lt;/P&gt;&lt;P&gt;&amp;nbsp;name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= "${var.prefix}-metastore"&lt;/P&gt;&lt;P&gt;&amp;nbsp;storage_root&amp;nbsp;= "s3://${aws_s3_bucket.metastore.id}/metastore"&lt;/P&gt;&lt;P&gt;&amp;nbsp;delta_sharing_scope = "INTERNAL"&lt;/P&gt;&lt;P&gt;&amp;nbsp;delta_sharing_recipient_token_lifetime_in_seconds = 120&lt;/P&gt;&lt;P&gt;&amp;nbsp;force_destroy = true&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Assign the metastore to workspaces&lt;/P&gt;&lt;P&gt;resource "databricks_metastore_assignment" "this" {&lt;/P&gt;&lt;P&gt;&amp;nbsp;provider&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= databricks.workspace&lt;/P&gt;&lt;P&gt;&amp;nbsp;count&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= length(var.workspaces)&lt;/P&gt;&lt;P&gt;&amp;nbsp;metastore_id = databricks_metastore.this.id&lt;/P&gt;&lt;P&gt;&amp;nbsp;workspace_id = tonumber(replace(var.workspaces[count.index], "/.*//", ""))&lt;/P&gt;&lt;P&gt;&amp;nbsp;depends_on&amp;nbsp;&amp;nbsp;= [ databricks_metastore.this ]&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;resource "databricks_metastore_data_access" "metastore_data_access" {&lt;/P&gt;&lt;P&gt;&amp;nbsp;provider&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= databricks.workspace&lt;/P&gt;&lt;P&gt;&amp;nbsp;metastore_id = databricks_metastore.this.id&lt;/P&gt;&lt;P&gt;&amp;nbsp;name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= aws_iam_role.metastore_data_access.name&lt;/P&gt;&lt;P&gt;&amp;nbsp;aws_iam_role { role_arn = aws_iam_role.metastore_data_access.arn }&lt;/P&gt;&lt;P&gt;&amp;nbsp;is_default&amp;nbsp;&amp;nbsp;= true&lt;/P&gt;&lt;P&gt;&amp;nbsp;depends_on&amp;nbsp;&amp;nbsp;= [ databricks_metastore_assignment.this ]&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 15:37:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/error-cannot-create-metastore-data-access-no-metastore-assigned/m-p/30980#M890</guid>
      <dc:creator>Andrei_Radulesc</dc:creator>
      <dc:date>2022-09-27T15:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Error: cannot create metastore data access: No metastore assigned for the current workspace.</title>
      <link>https://community.databricks.com/t5/data-governance/error-cannot-create-metastore-data-access-no-metastore-assigned/m-p/30981#M891</link>
      <description>&lt;P&gt;Yes, I get this would help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is that ideally I would like to avoid assigning the metastore to workspace before databricks_metastore_data_access&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My initial plan was to put unit catalog deployment to separate folder in the terraform structure and each workspace as well:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dev/&lt;/P&gt;&lt;P&gt;dev/uc&lt;/P&gt;&lt;P&gt;dev/ws_1&lt;/P&gt;&lt;P&gt;dev/ws_2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but I guess that I will need to re-think this. The order of the steps confused me a bit &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2022 16:56:31 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/error-cannot-create-metastore-data-access-no-metastore-assigned/m-p/30981#M891</guid>
      <dc:creator>Pat</dc:creator>
      <dc:date>2022-09-27T16:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Error: cannot create metastore data access: No metastore assigned for the current workspace.</title>
      <link>https://community.databricks.com/t5/data-governance/error-cannot-create-metastore-data-access-no-metastore-assigned/m-p/30982#M892</link>
      <description>&lt;P&gt;Hi @Pat Sienkiewicz​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We'd love to hear from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 05:29:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/error-cannot-create-metastore-data-access-no-metastore-assigned/m-p/30982#M892</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-17T05:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Error: cannot create metastore data access: No metastore assigned for the current workspace.</title>
      <link>https://community.databricks.com/t5/data-governance/error-cannot-create-metastore-data-access-no-metastore-assigned/m-p/38411#M1112</link>
      <description>&lt;P&gt;Hi, I'm experiencing a similar issue. I filed an Issue on Github &lt;A href="https://github.com/databricks/terraform-provider-databricks/issues/2513#issuecomment-1650369549" target="_self"&gt;here&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 19:52:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/error-cannot-create-metastore-data-access-no-metastore-assigned/m-p/38411#M1112</guid>
      <dc:creator>pwc-aiq</dc:creator>
      <dc:date>2023-07-25T19:52:37Z</dc:date>
    </item>
  </channel>
</rss>

