databricks / cli

Databricks CLI
Other
150 stars 56 forks source link

Added support for Databricks Apps in DABs #1928

Open andrewnester opened 1 day ago

andrewnester commented 1 day ago

Changes

Added support for Databricks Apps in DABs.

It's possible to configure new app resource in bundle and point it to the custom source_code_path location where Databricks App code is define. On databricks bundle deploy DABs will create an app and execute app deployment with the pointed files. All consecutive databricks bundle deploy execution will trigger new app deployments.

Here's an example of configuration:

bundle:
  name: apps

variables:
  my_job_id:
    description: "ID of job to run app"
    lookup:
      job: "My Job"
  databricks_name:
    description: "Name for app user"
  additional_flags:
    description: "Additional flags to run command app"
    default: ""
  my_app_config:
    type: complex
    description: "Configuration for my Databricks App"
    default:
      command:
        - flask
        - --app
        - hello
        - run
        - ${var.additional_flags}
      env:
        - name: DATABRICKS_NAME
          value: ${var.databricks_name}

resources:
  apps:
    my_app:
      name: "anester-app" # required and has to be unique
      description: "My App"
      source_code_path: ./app # required and points to location of app code
      config: ${var.my_app_config}
      resources:
        - name: "my-job"
          description: "A job for app to be able to run"
          job:
            id: ${var.my_job_id}
            permission: "CAN_MANAGE_RUN"
      permissions:
        - user_name: "foo@bar.com"
          level: "CAN_VIEW"
        - service_principal_name: "my_sp"
          level: "CAN_MANAGE"

targets:
  dev:
    variables:
      databricks_name: "Andrew (from dev)"
      additional_flags: --debug

  prod:
    variables:
      databricks_name: "Andrew (from prod)"

Note: relies on not yet released TF change: https://github.com/databricks/terraform-provider-databricks/pull/4099

TODO:

Tests

Added unit and config tests + manual test.

github-actions[bot] commented 1 day ago

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger: go/deco-tests-run/cli

Inputs:

Checks will be approved automatically on success.

eng-dev-ecosystem-bot commented 1 day ago

Test Details: go/deco-tests/11957790217