Skip to content

Add app_spaces as a DABs resource type (direct mode only)#4982

Open
bernardo-rodriguez wants to merge 2 commits intodatabricks:mainfrom
bernardo-rodriguez:add-app-spaces-dabs-resource
Open

Add app_spaces as a DABs resource type (direct mode only)#4982
bernardo-rodriguez wants to merge 2 commits intodatabricks:mainfrom
bernardo-rodriguez:add-app-spaces-dabs-resource

Conversation

@bernardo-rodriguez
Copy link
Copy Markdown

@bernardo-rodriguez bernardo-rodriguez commented Apr 16, 2026

Changes

Adds support for declaring Databricks App Spaces in bundle YAML via the app_spaces resource type. Spaces are containers for apps that provide shared resources, OAuth scopes, and a service principal.

Implements direct mode CRUD with async operation waiting, a merge mutator for the space resources array, run_as validation, and test server handlers for the fake workspace.

Why

App spaces are are in private preview, we want to add support for the developer ecosystem.

Tests

Tested with local CLI build.

Test databricks.yml file:

resources:
  app_spaces:
    space_with_resources:
      name: test-space-with-resources
      description: "A space with shared resources"
      resources:
        - name: my-serving-endpoint
          serving_endpoint:
            name: databricks-meta-llama-3-3-70b-instruct
            permission: CAN_QUERY
        - name: my-warehouse                                                                                                        
          sql_warehouse:                                                                                                            
            id: 668e77c7ff1fce2d                          
            permission: CAN_USE
  apps:
    my_app:
      name: app-in-space
      space: ${resources.app_spaces.space_with_resources.name}
      source_code_path: ./my-app
      lifecycle:                                                                                                                    
        started: true
      config:
        command:
          - python
          - app.py
        env:
          - name: APP_ENV
            value: staging

Commands:

DATABRICKS_BUNDLE_ENGINE=direct ../cli/databricks bundle deploy
Uploading bundle files to /Workspace/Users/bernardo.rodriguez@databricks.com/.bundle/test-app-spaces/dev/files...
Deploying resources...
Updating deployment state...
Deployment complete!

New app space:

databricks apps get-space test-space-with-resources
{
  "create_time":"2026-04-16T01:40:18Z",
  "creator":"bernardo.rodriguez@databricks.com",
  "description":"A space with shared resources",
  "name":"test-space-with-resources",
  "resources": [
    {
      "name":"my-serving-endpoint",
      "serving_endpoint": {
        "name":"databricks-meta-llama-3-3-70b-instruct",
        "permission":"CAN_QUERY"
      }
    },
    {
      "name":"my-warehouse",
      "sql_warehouse": {
        "id":"668e77c7ff1fce2d",
        "permission":"CAN_USE"
      }
    }
  ],
  "status": {
    "message":"Space is ready.",
    "state":"SPACE_ACTIVE"
  },
  ...
}

New App:

databricks apps get app-in-space
{
  "app_status": {
    "message":"App has status: App has not been deployed yet. Run your app by deploying source code",
    "state":"UNAVAILABLE"
  },
  "compute_size":"LIQUID",
  "compute_status": {
    "message":"App compute is running.",
    "state":"ACTIVE"
  },
  "create_time":"2026-04-16T01:40:25Z",
  "creator":"bernardo.rodriguez@databricks.com",
  "description":"",
  "effective_user_api_scopes": [
    "iam.current-user:read",
    "iam.access-control:read"
  ],
  "name":"app-in-space",
  "space":"test-space-with-resources",
  "update_time":"2026-04-16T01:41:22Z",
  "updater":"bernardo.rodriguez@databricks.com",
  "url":"https://app-in-space-4119111590058294.0.staging.azure.databricksapps.com",
   ....
}
  • Test updating the app spaces with new resource and running bundle deploy makes desired updates
  • Test removing the app spaces from the yml file and deploying deletes the app spaces
  • Test bundle destroy deletes the app spaces
  • Unit tests

Adds support for declaring Databricks App Spaces in bundle YAML via
the `app_spaces` resource type. Spaces are containers for apps that
provide shared resources, OAuth scopes, and a service principal.

Implements direct mode CRUD with async operation waiting, a merge
mutator for the space resources array, run_as validation, and test
server handlers for the fake workspace.

Co-authored-by: Isaac
@github-actions
Copy link
Copy Markdown

Approval status: pending

/bundle/ - needs approval

Files: bundle/config/mutator/resourcemutator/apply_bundle_permissions_test.go, bundle/config/mutator/resourcemutator/apply_target_mode_test.go, bundle/config/mutator/resourcemutator/merge_app_spaces.go, bundle/config/mutator/resourcemutator/resource_mutator.go, bundle/config/mutator/resourcemutator/run_as.go, bundle/config/mutator/resourcemutator/run_as_test.go, bundle/config/resources.go, bundle/config/resources/app_spaces.go, bundle/config/resources_test.go, bundle/direct/dresources/all.go, bundle/direct/dresources/all_test.go, bundle/direct/dresources/app_space.go, bundle/direct/dresources/resources.yml
Suggested: @denik
Also eligible: @andrewnester, @shreyas-goenka, @pietern, @anton-107, @lennartkats-db, @janniklasrose

General files (require maintainer)

Files: libs/testserver/app_spaces.go, libs/testserver/fake_workspace.go, libs/testserver/handlers.go
Based on git history:

  • @denik -- recent work in bundle/direct/dresources/, libs/testserver/, bundle/config/mutator/resourcemutator/

Any maintainer (@andrewnester, @anton-107, @denik, @pietern, @shreyas-goenka, @simonfaltum, @renaudhartert-db) can approve all areas.
See OWNERS for ownership rules.

The Spaces API rejects wildcard update masks. Use the explicit list
of updatable fields: description, resources, user_api_scopes,
usage_policy_id.

Co-authored-by: Isaac
@github-actions
Copy link
Copy Markdown

An authorized user can trigger integration tests manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 4982
  • Commit SHA: 741eba28aec15d636d894ac4ade8a002b4172e16

Checks will be approved automatically on success.

Copy link
Copy Markdown
Contributor

@andrewnester andrewnester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add acceptance test for the new resource, see for example

https://github.com/databricks/cli/tree/main/acceptance/bundle/resources/apps/update

if err != nil {
return "", nil, err
}
space, err := waiter.Wait(ctx)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a separate WaitAfterCreate / Update method to wait fo this resources to be created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants