Lookup dashboard ID in bundle variables

ddundovic
New Contributor III

Hi all,

I have an asset bundle that contains the following dashboard_task:

resources:
  jobs:
    my_job:
      name: my_job_name

      tasks:
        - task_key: refresh_my_dashboard
          dashboard_task:
            dashboard_id: ${var.my_dashboard_id}

Here I would like to use the `my_dashboard_id` variable, so that it automatically substitutes the ID of the dashboard when deployed on different workspaces. So in my `databricks.yml` file, at bundle level, I have the following variables mapping:

variables:
  my_dashboard_id:
    lookup:
      dashboard: My_Dashboard_Name

 However, this returns an error during bundle validation:

Error: failed to resolve dashboard: My_Dashboard_Name, err: Dashboard named 'My_Dashboard_Name' does not exist

I am certain that the dashboard exists and that I have the necessary permissions.

Furthermore, when I run `databricks dashboards list`, no dashboards are found. I saw in the databricks cli documentation that `databricks dashboards` are commands for modifying legacy dashboards. This would explain why no dashboards are found when I run that. Is it possible that the lookup in the bundle configuration also looks for legacy dashboards?

Any help with getting this work would be much appreciated. Thanks!