Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
842e8ec
Add postgres_data_apis bundle resource
ruslantalpa Oct 20, 2026
609a5c5
Match the testserver Data API fake to the real API
ruslantalpa Oct 20, 2026
a2c35e8
Detect postgres_data_apis spec drift by reading the spec from status
ruslantalpa Oct 20, 2026
38e69e9
Add PR link to postgres_data_apis changelog entry
ruslantalpa Oct 21, 2026
2115d85
Report status.url from the testserver Data API fake
ruslantalpa Oct 21, 2026
e0716ad
Declare postgres_data_apis status.url a stable output field
ruslantalpa Oct 21, 2026
9aed236
Cover bools, durations and openapi_mode in the Data API invariant config
ruslantalpa Oct 21, 2026
b8a1c0e
Describe postgres_data_apis and OpenApiMode in the bundle schema
ruslantalpa Oct 21, 2026
eb2b84f
Keep the launchStageOverrides alignment unchanged
ruslantalpa Oct 21, 2026
e412b28
Update changelog entry to link #7160
ruslantalpa Oct 22, 2026
12880b2
Use bash 3.2-compatible redirect in postgres_data_api bind test
ruslantalpa Oct 22, 2026
3ab66ef
Skip DMS runs for postgres_data_apis until deployment history accepts it
ruslantalpa Oct 23, 2026
b7d7cad
Regenerate postgres_data_apis outputs after rebase onto main
ruslantalpa Nov 2, 2026
b83bc7f
Skip DMS runs for the postgres_data_api bind test
ruslantalpa Nov 2, 2026
a07dc42
Declare the production branch in the Data API acceptance tests
ruslantalpa Nov 3, 2026
46d77f5
Reject a postgres_data_apis entry that sets only parent
ruslantalpa Nov 3, 2026
ab7d1a8
Document Data API field removal and status.url limitations
ruslantalpa Nov 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nextchanges/bundles/postgres-data-apis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Add the `postgres_data_apis` resource (Private Preview) for enabling and configuring the Data API of a Lakebase Postgres database. ([#7160](https://github.com/databricks/cli/pull/7160))
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
bundle:
name: test-bundle

resources:
postgres_data_apis:
data_api1:
parent: projects/test-project/branches/production/databases/test-database
db_schemas:
- public
db_max_rows: 500
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = false
EnvMatrix.DMS = [""]
94 changes: 94 additions & 0 deletions acceptance/bundle/deployment/bind/postgres_data_api/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@

=== Enable the Data API on a database outside the bundle
=== Deploy fails because the Data API is already enabled
>>> musterr [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
Error: cannot create resources.postgres_data_apis.data_api1: Data API is already enabled for this database (409 ALREADY_EXISTS)

Endpoint: POST [DATABRICKS_URL]/api/2.0/postgres/projects/test-project/branches/production/databases/test-database/data-api
HTTP Status: 409 Conflict
API error_code: ALREADY_EXISTS
API message: Data API is already enabled for this database

Files: 2 uploaded, 0 deleted

=== Bind adopts the existing Data API
>>> [CLI] bundle deployment bind data_api1 projects/test-project/branches/production/databases/test-database/data-api --auto-approve
Successfully bound postgres_data_api with an id 'projects/test-project/branches/production/databases/test-database/data-api'
Run 'bundle deploy' to deploy changes to your workspace

>>> [CLI] bundle summary
Name: test-bundle
Target: default
Workspace:
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default
Resources:
Postgres Data APIs:
data_api1:
Name: projects/test-project/branches/production/databases/test-database/data-api

>>> [CLI] bundle plan
update postgres_data_apis.data_api1

Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
Updated postgres_data_apis.data_api1
Files: 0 uploaded, 0 deleted
Resources: 0 created, 1 changed, 0 deleted, 0 unchanged

>>> [CLI] postgres get-data-api projects/test-project/branches/production/databases/test-database/data-api
{
"name": "projects/test-project/branches/production/databases/test-database/data-api",
"status": {
"db_schemas": [
"public"
],
"db_max_rows": 500
}
}

>>> [CLI] bundle plan
Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged

=== Unbind leaves the Data API enabled
>>> [CLI] bundle deployment unbind data_api1

>>> [CLI] bundle summary
Name: test-bundle
Target: default
Workspace:
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default
Resources:
Postgres Data APIs:
data_api1:
Name:

>>> [CLI] postgres get-data-api projects/test-project/branches/production/databases/test-database/data-api
{
"name": "projects/test-project/branches/production/databases/test-database/data-api"
}

=== Bind again; destroy turns off the Data API
>>> [CLI] bundle deployment bind data_api1 projects/test-project/branches/production/databases/test-database/data-api --auto-approve
Successfully bound postgres_data_api with an id 'projects/test-project/branches/production/databases/test-database/data-api'
Run 'bundle deploy' to deploy changes to your workspace

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete resources.postgres_data_apis.data_api1

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default

Destroy: 1 deleted

>>> musterr [CLI] postgres get-data-api projects/test-project/branches/production/databases/test-database/data-api
Error: Data API is not enabled for this database

>>> [CLI] postgres get-database projects/test-project/branches/production/databases/test-database
{
"name": "projects/test-project/branches/production/databases/test-database"
}
31 changes: 31 additions & 0 deletions acceptance/bundle/deployment/bind/postgres_data_api/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
DATABASE_NAME="projects/test-project/branches/production/databases/test-database"
DATA_API_NAME="${DATABASE_NAME}/data-api"

title "Enable the Data API on a database outside the bundle"
$CLI postgres create-project test-project --json '{"spec": {"display_name": "Test Project", "pg_version": 16}}' &> LOG.setup
$CLI postgres create-database projects/test-project/branches/production --database-id test-database --json '{"spec": {"postgres_database": "app_db", "role": "projects/test-project/branches/production/roles/owner"}}' >> LOG.setup 2>&1
$CLI postgres create-data-api "${DATABASE_NAME}" --json '{"spec": {"db_schemas": ["public"]}}' >> LOG.setup 2>&1

title "Deploy fails because the Data API is already enabled"
trace musterr $CLI bundle deploy

title "Bind adopts the existing Data API"
# Bind records the config as state. The plan compares it with the spec read back
# from status, so the configured db_max_rows is applied on the next deploy.
trace $CLI bundle deployment bind data_api1 "${DATA_API_NAME}" --auto-approve
trace $CLI bundle summary
trace $CLI bundle plan
trace $CLI bundle deploy
trace $CLI postgres get-data-api "${DATA_API_NAME}" | jq '{name, status: (.status | {db_schemas, db_max_rows})}'
trace $CLI bundle plan

title "Unbind leaves the Data API enabled"
trace $CLI bundle deployment unbind data_api1
trace $CLI bundle summary
trace $CLI postgres get-data-api "${DATA_API_NAME}" | jq '{name}'

title "Bind again; destroy turns off the Data API"
trace $CLI bundle deployment bind data_api1 "${DATA_API_NAME}" --auto-approve
trace $CLI bundle destroy --auto-approve
trace musterr $CLI postgres get-data-api "${DATA_API_NAME}"
trace $CLI postgres get-database "${DATABASE_NAME}" | jq '{name}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Cloud = false

# Deployment history has no "postgres_data_apis." resource-key prefix yet. See dmsResourceTypes in
# libs/testserver/bundledeployments.go, which mirrors Universe.
EnvMatrixExclude.no_data_api_dms = ["DMS=true"]

Ignore = [
".databricks"
]
2 changes: 2 additions & 0 deletions acceptance/bundle/invariant/auto-migrate/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ EnvMatrixExclude.no_cluster_libraries = ["INPUT_CONFIG=cluster_libraries.yml.tmp
EnvMatrixExclude.no_model_service = ["INPUT_CONFIG=model_service.yml.tmpl"]
# Features are direct-only; the terraform deploy that seeds the migration fails for them.
EnvMatrixExclude.no_feature = ["INPUT_CONFIG=feature.yml.tmpl"]
# The Postgres Data API is direct-only; the terraform deploy that seeds the migration fails for it.
EnvMatrixExclude.no_postgres_data_api = ["INPUT_CONFIG=postgres_data_api.yml.tmpl"]

# Cross-resource permission references (e.g. ${resources.jobs.job_b.permissions[0].level})
# don't work in terraform mode: the terraform interpolator converts the path to
Expand Down
45 changes: 45 additions & 0 deletions acceptance/bundle/invariant/configs/postgres_data_api.yml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
bundle:
name: test-bundle-$UNIQUE_NAME

resources:
postgres_projects:
project:
project_id: test-pg-project-$UNIQUE_NAME
display_name: Test Postgres Project

# The Data API needs a read-write endpoint on the branch. Take over the
# "production" branch created with the project, which comes with one.
postgres_branches:
production:
parent: ${resources.postgres_projects.project.name}
branch_id: production
replace_existing: true
no_expiry: true

postgres_roles:
owner:
parent: ${resources.postgres_branches.production.name}
role_id: test-role-$UNIQUE_NAME
postgres_role: app_role

postgres_databases:
database:
parent: ${resources.postgres_branches.production.name}
database_id: test-database-$UNIQUE_NAME
postgres_database: app_db
role: ${resources.postgres_roles.owner.name}

postgres_data_apis:
foo:
parent: ${resources.postgres_databases.database.name}
db_schemas:
- public
db_max_rows: 1000 # CAN_REMOVE
server_cors_allowed_origins: # CAN_REMOVE
- https://app.example.com # CAN_REMOVE
jwt_cache_max_lifetime: 300s # CAN_REMOVE
openapi_mode: OPEN_API_MODE_IGNORE_PRIVILEGES # CAN_REMOVE
# Removing a bool converges like the other fields: the server keeps the
# last value and status reports it.
db_aggregates_enabled: false # CAN_REMOVE
server_timing_enabled: true # CAN_REMOVE
3 changes: 3 additions & 0 deletions acceptance/bundle/invariant/continue_293/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ EnvMatrixExclude.no_pydabs_1000_tasks = ["INPUT_CONFIG=job_pydabs_1000_tasks.yml
# secret resource is not supported on v0.293.0
EnvMatrixExclude.no_secret = ["INPUT_CONFIG=secret.yml.tmpl"]

# postgres_data_apis resource is not supported on v0.293.0
EnvMatrixExclude.no_postgres_data_api = ["INPUT_CONFIG=postgres_data_api.yml.tmpl"]

# $${...} escaping is not supported on v0.293.0: the seed deploy fails with
# 'invalid dependency "${batch_id}", no such node ""' (issue #6480).
EnvMatrixExclude.no_escaped_refs = ["INPUT_CONFIG=job_escaped_refs.yml.tmpl"]
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ EnvMatrix.INPUT_CONFIG = [
"pipeline_config_dots.yml.tmpl",
"postgres_branch.yml.tmpl",
"postgres_catalog.yml.tmpl",
"postgres_data_api.yml.tmpl",
"postgres_database.yml.tmpl",
"postgres_endpoint.yml.tmpl",
"postgres_project.yml.tmpl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ EnvMatrix.INPUT_CONFIG = [
"pipeline_config_dots.yml.tmpl",
"postgres_branch.yml.tmpl",
"postgres_catalog.yml.tmpl",
"postgres_data_api.yml.tmpl",
"postgres_database.yml.tmpl",
"postgres_endpoint.yml.tmpl",
"postgres_project.yml.tmpl",
Expand Down
2 changes: 2 additions & 0 deletions acceptance/bundle/invariant/migrate/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ EnvMatrixExclude.no_cluster_libraries = ["INPUT_CONFIG=cluster_libraries.yml.tmp
EnvMatrixExclude.no_model_service = ["INPUT_CONFIG=model_service.yml.tmpl"]
# Features are direct-only; the terraform deploy that seeds the migration fails for them.
EnvMatrixExclude.no_feature = ["INPUT_CONFIG=feature.yml.tmpl"]
# The Postgres Data API is direct-only; the terraform deploy that seeds the migration fails for it.
EnvMatrixExclude.no_postgres_data_api = ["INPUT_CONFIG=postgres_data_api.yml.tmpl"]

# Cross-resource permission references (e.g. ${resources.jobs.job_b.permissions[0].level})
# don't work in terraform mode: the terraform interpolator converts the path to
Expand Down
1 change: 1 addition & 0 deletions acceptance/bundle/invariant/no_drift/out.test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ EnvMatrix.INPUT_CONFIG = [
"pipeline_config_dots.yml.tmpl",
"postgres_branch.yml.tmpl",
"postgres_catalog.yml.tmpl",
"postgres_data_api.yml.tmpl",
"postgres_database.yml.tmpl",
"postgres_endpoint.yml.tmpl",
"postgres_project.yml.tmpl",
Expand Down
4 changes: 4 additions & 0 deletions acceptance/bundle/invariant/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ EnvMatrix.INPUT_CONFIG = [
"pipeline_config_dots.yml.tmpl",
"postgres_branch.yml.tmpl",
"postgres_catalog.yml.tmpl",
"postgres_data_api.yml.tmpl",
"postgres_database.yml.tmpl",
"postgres_endpoint.yml.tmpl",
"postgres_project.yml.tmpl",
Expand Down Expand Up @@ -94,6 +95,7 @@ EnvMatrixExclude.no_postgres_catalog_on_cloud = ["CONFIG_Cloud=true", "INPUT_CON
EnvMatrixExclude.no_postgres_synced_table_on_cloud = ["CONFIG_Cloud=true", "INPUT_CONFIG=postgres_synced_table.yml.tmpl"]
EnvMatrixExclude.no_postgres_role_on_cloud = ["CONFIG_Cloud=true", "INPUT_CONFIG=postgres_role.yml.tmpl"]
EnvMatrixExclude.no_postgres_database_on_cloud = ["CONFIG_Cloud=true", "INPUT_CONFIG=postgres_database.yml.tmpl"]
EnvMatrixExclude.no_postgres_data_api_on_cloud = ["CONFIG_Cloud=true", "INPUT_CONFIG=postgres_data_api.yml.tmpl"]
# Lakebase v1 (database instances/catalogs/synced tables) is not available on GCP,
# so exclude these from all cloud runs (same as the postgres resources above).
EnvMatrixExclude.no_database_instance_on_cloud = ["CONFIG_Cloud=true", "INPUT_CONFIG=database_instance.yml.tmpl"]
Expand All @@ -119,6 +121,8 @@ EnvMatrixExclude.no_model_service_on_cloud = ["CONFIG_Cloud=true", "INPUT_CONFIG
# Deployment history has no "features." resource-key prefix, so the deploy fails before the feature
# is created; see dmsResourceTypes in libs/testserver/bundledeployments.go.
EnvMatrixExclude.no_feature_dms = ["DMS=true", "INPUT_CONFIG=feature.yml.tmpl"]
# Same for the "postgres_data_apis." prefix.
EnvMatrixExclude.no_postgres_data_api_dms = ["DMS=true", "INPUT_CONFIG=postgres_data_api.yml.tmpl"]
# Fake SQL endpoint for local tests

[[Server]]
Expand Down
40 changes: 40 additions & 0 deletions acceptance/bundle/refschema/output/postgres_data_apis.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
resources.postgres_data_apis.*.create_time *time.Time REMOTE
resources.postgres_data_apis.*.db_aggregates_enabled bool ALL
resources.postgres_data_apis.*.db_extra_search_path []string ALL
resources.postgres_data_apis.*.db_extra_search_path[*] string ALL
resources.postgres_data_apis.*.db_max_rows int ALL
resources.postgres_data_apis.*.db_schemas []string ALL
resources.postgres_data_apis.*.db_schemas[*] string ALL
resources.postgres_data_apis.*.id string INPUT
resources.postgres_data_apis.*.jwt_cache_max_lifetime *duration.Duration ALL
resources.postgres_data_apis.*.jwt_role_claim_key string ALL
resources.postgres_data_apis.*.lifecycle resources.Lifecycle INPUT
resources.postgres_data_apis.*.lifecycle.depends_on []resources.DependsOn INPUT
resources.postgres_data_apis.*.lifecycle.depends_on[*] resources.DependsOn INPUT
resources.postgres_data_apis.*.lifecycle.depends_on[*].resource string INPUT
resources.postgres_data_apis.*.lifecycle.prevent_destroy bool INPUT
resources.postgres_data_apis.*.modified_status string INPUT
resources.postgres_data_apis.*.name string REMOTE
resources.postgres_data_apis.*.openapi_mode postgres.OpenApiMode ALL
resources.postgres_data_apis.*.parent string ALL
resources.postgres_data_apis.*.server_cors_allowed_origins []string ALL
resources.postgres_data_apis.*.server_cors_allowed_origins[*] string ALL
resources.postgres_data_apis.*.server_timing_enabled bool ALL
resources.postgres_data_apis.*.status *postgres.DataApiDataApiStatus REMOTE
resources.postgres_data_apis.*.status.available_schemas []string REMOTE
resources.postgres_data_apis.*.status.available_schemas[*] string REMOTE
resources.postgres_data_apis.*.status.db_aggregates_enabled bool REMOTE
resources.postgres_data_apis.*.status.db_extra_search_path []string REMOTE
resources.postgres_data_apis.*.status.db_extra_search_path[*] string REMOTE
resources.postgres_data_apis.*.status.db_max_rows int REMOTE
resources.postgres_data_apis.*.status.db_schemas []string REMOTE
resources.postgres_data_apis.*.status.db_schemas[*] string REMOTE
resources.postgres_data_apis.*.status.jwt_cache_max_lifetime *duration.Duration REMOTE
resources.postgres_data_apis.*.status.jwt_role_claim_key string REMOTE
resources.postgres_data_apis.*.status.openapi_mode postgres.OpenApiMode REMOTE
resources.postgres_data_apis.*.status.server_cors_allowed_origins []string REMOTE
resources.postgres_data_apis.*.status.server_cors_allowed_origins[*] string REMOTE
resources.postgres_data_apis.*.status.server_timing_enabled bool REMOTE
resources.postgres_data_apis.*.status.url string REMOTE
resources.postgres_data_apis.*.update_time *time.Time REMOTE
resources.postgres_data_apis.*.url string INPUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
bundle:
name: deploy-pg-data-api-$UNIQUE_NAME

sync:
paths: []

resources:
postgres_projects:
my_project:
project_id: test-pg-proj-$UNIQUE_NAME
display_name: "Test Project for Data API"
pg_version: 16

# The Data API needs a read-write endpoint on the branch. Take over the
# "production" branch created with the project, which comes with one.
postgres_branches:
production:
parent: ${resources.postgres_projects.my_project.id}
branch_id: production
replace_existing: true
no_expiry: true

postgres_roles:

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.

This is an implicit dep on the branch; please include it in the config with replace_existing to pull it in.

Same for the other acc tests.

owner:
parent: ${resources.postgres_branches.production.id}
role_id: app-owner
postgres_role: app_owner

postgres_databases:
my_database:
parent: ${resources.postgres_branches.production.id}
database_id: my-database
postgres_database: app_db
role: ${resources.postgres_roles.owner.id}

postgres_data_apis:
my_data_api:
parent: ${resources.postgres_databases.my_database.name}
db_schemas:
- public
db_max_rows: 100
Loading
Loading