Skip to content

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

Open
bernardo-rodriguez wants to merge 5 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 5 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

github-actions bot commented Apr 16, 2026

Approval status: pending

/acceptance/bundle/ - needs approval

Files: acceptance/bundle/resources/app_spaces/basic/databricks.yml, acceptance/bundle/resources/app_spaces/basic/out.requests.direct.json, acceptance/bundle/resources/app_spaces/basic/out.test.toml, acceptance/bundle/resources/app_spaces/basic/output.txt, acceptance/bundle/resources/app_spaces/basic/script, acceptance/bundle/resources/app_spaces/basic/test.toml, acceptance/bundle/resources/app_spaces/recreate/databricks.yml, acceptance/bundle/resources/app_spaces/recreate/out.requests.direct.json, acceptance/bundle/resources/app_spaces/recreate/out.test.toml, acceptance/bundle/resources/app_spaces/recreate/output.txt, acceptance/bundle/resources/app_spaces/recreate/script, acceptance/bundle/resources/app_spaces/recreate/test.toml, acceptance/bundle/resources/app_spaces/update/databricks.yml, acceptance/bundle/resources/app_spaces/update/out.requests.direct.json, acceptance/bundle/resources/app_spaces/update/out.test.toml, acceptance/bundle/resources/app_spaces/update/output.txt, acceptance/bundle/resources/app_spaces/update/script, acceptance/bundle/resources/app_spaces/update/test.toml
Suggested: @denik
Also eligible: @andrewnester, @shreyas-goenka, @pietern, @anton-107, @lennartkats-db, @janniklasrose

/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, bundle/internal/schema/annotations.yml, bundle/schema/jsonschema.json
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
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

Comment thread bundle/direct/dresources/app_space.go Outdated
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

- Add nolint comment for Id field collision between BaseResource and
  apps.Space (same pattern as App resource)
- Regenerate annotations.yml and jsonschema.json via make schema
- Add acceptance tests: basic (with nested resources), recreate (name
  immutability), update (create/update/rename/destroy lifecycle)

Co-authored-by: Isaac
Previous golden files were generated with Python 3.6 which doesn't
support f-string self-documenting expressions used in update_file.py,
causing bogus SyntaxError output that would fail in CI.

Co-authored-by: Isaac
Previously DoCreate and DoUpdate blocked on waiter.Wait, preventing
the direct engine from parallelizing operations across resources.
Move the wait into dedicated WaitAfterCreate/WaitAfterUpdate methods
that poll GetSpace until the space reaches SPACE_ACTIVE state.

Addresses review feedback from @andrewnester.

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: 6991ad39a37efb32aa2074598415f54672c30e36

Checks will be approved automatically on success.

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