|
1 | 1 | --- |
2 | | -description: Run Aidbox on managed PostgreSQL services like AWS Aurora, Azure Database, and GCP Cloud SQL. Setup guide for extensions and user configuration. |
| 2 | +description: Run Aidbox on managed PostgreSQL services like AWS Aurora, Azure Database, GCP Cloud SQL, and Databricks Lakebase. Setup guide for extensions and user configuration. |
3 | 3 | --- |
4 | 4 |
|
5 | 5 | # Run Aidbox on managed PostgreSQL |
@@ -39,6 +39,65 @@ Follow [Azure Documentation](https://learn.microsoft.com/en-us/azure/postgresql/ |
39 | 39 | CREATE USER aidbox WITH CREATEDB ENCRYPTED PASSWORD 'aidboxpass'; |
40 | 40 | ``` |
41 | 41 |
|
| 42 | +### Databricks Lakebase |
| 43 | + |
| 44 | +#### Prerequisites |
| 45 | + |
| 46 | +* A Databricks workspace with [Lakebase Postgres](https://docs.databricks.com/aws/en/oltp/) enabled |
| 47 | +* A [service principal](https://docs.databricks.com/aws/en/admin/users-groups/service-principals) with a generated OAuth secret, [added to the workspace](https://docs.databricks.com/aws/en/admin/users-groups/service-principals#add-a-service-principal-to-a-workspace) |
| 48 | +* Follow [Databricks documentation](https://docs.databricks.com/aws/en/oltp/instances/pg-roles?language=PostgreSQL) to create a PostgreSQL role for the service principal |
| 49 | +* The database must already exist before starting Aidbox — Aidbox will not create it automatically when using Databricks authentication |
| 50 | + |
| 51 | +#### Configure Aidbox |
| 52 | + |
| 53 | +Lakebase uses OAuth token-based authentication. Aidbox supports both Lakebase deployment modes: [Provisioned](https://docs.databricks.com/aws/en/oltp/instances/) (fixed-capacity instances) and [Autoscaling](https://docs.databricks.com/aws/en/oltp/projects/about) (scale-to-zero projects). |
| 54 | + |
| 55 | +Aidbox fetches short-lived tokens (1 hour expiry) from Databricks and caches them for 45 minutes (configurable via `BOX_DB_CREDENTIAL_REFRESH_INTERVAL`). When the cache expires, a fresh token is fetched on the next connection. HikariCP `max-lifetime` is set to match the cache TTL so existing connections rotate before tokens expire. SSL is enforced automatically. |
| 56 | + |
| 57 | +{% tabs %} |
| 58 | +{% tab title="Provisioned" %} |
| 59 | +```shell |
| 60 | +BOX_DB_HOST=<instance-id>.database.cloud.databricks.com |
| 61 | +BOX_DB_PORT=5432 |
| 62 | +BOX_DB_DATABASE=databricks_postgres |
| 63 | +BOX_DB_USER=<client-id> |
| 64 | +BOX_DB_PASSWORD=placeholder |
| 65 | + |
| 66 | +BOX_DB_AUTH_METHOD=databricks-provisioned |
| 67 | +BOX_DB_DATABRICKS_HOST=https://your-workspace.cloud.databricks.com |
| 68 | +BOX_DB_DATABRICKS_PROVISIONED_INSTANCE_NAME=<instance-name> |
| 69 | +BOX_DB_DATABRICKS_CLIENT_ID=<client-id> |
| 70 | +BOX_DB_DATABRICKS_CLIENT_SECRET=<client-secret> |
| 71 | +BOX_DB_DATABRICKS_SCOPE=all-apis |
| 72 | +``` |
| 73 | +{% endtab %} |
| 74 | +{% tab title="Autoscaling" %} |
| 75 | +```shell |
| 76 | +BOX_DB_HOST=<project-id>.database.cloud.databricks.com |
| 77 | +BOX_DB_PORT=5432 |
| 78 | +BOX_DB_DATABASE=databricks_postgres |
| 79 | +BOX_DB_USER=<client-id> |
| 80 | +BOX_DB_PASSWORD=placeholder |
| 81 | + |
| 82 | +BOX_DB_AUTH_METHOD=databricks-autoscale |
| 83 | +BOX_DB_DATABRICKS_HOST=https://your-workspace.cloud.databricks.com |
| 84 | +BOX_DB_DATABRICKS_AUTOSCALE_ENDPOINT=projects/<project-id>/branches/<branch-id>/endpoints/<endpoint-id> |
| 85 | +BOX_DB_DATABRICKS_CLIENT_ID=<client-id> |
| 86 | +BOX_DB_DATABRICKS_CLIENT_SECRET=<client-secret> |
| 87 | +BOX_DB_DATABRICKS_SCOPE=all-apis |
| 88 | +``` |
| 89 | +{% endtab %} |
| 90 | +{% endtabs %} |
| 91 | + |
| 92 | +{% hint style="info" %} |
| 93 | +`BOX_DB_USER` and `BOX_DB_DATABRICKS_CLIENT_ID` are both the service principal's application ID. |
| 94 | +`BOX_DB_PASSWORD` is a placeholder — the credentials provider overrides it. |
| 95 | +`BOX_DB_DATABRICKS_HOST` is the workspace URL (from your browser), not the database hostname. |
| 96 | +`BOX_DB_DATABRICKS_SCOPE` defaults to `all-apis`. Do not change unless you know your workspace requires a different scope. |
| 97 | +`BOX_DB_CREDENTIAL_REFRESH_INTERVAL` controls the token cache TTL in milliseconds (default: `2700000`, i.e. 45 minutes). Should be less than the Databricks token expiry (60 minutes). |
| 98 | +The same auth settings are available for read-only replica with the `BOX_DB_RO_REPLICA_*` prefix (e.g. `BOX_DB_RO_REPLICA_AUTH_METHOD`, `BOX_DB_RO_REPLICA_DATABRICKS_HOST`, etc.). |
| 99 | +{% endhint %} |
| 100 | + |
42 | 101 | ### Disable installation of PostgreSQL extensions on Aidbox startup  |
43 | 102 |
|
44 | 103 | If your PostgreSQL user used by Aidbox does not have sufficient privileges to install extensions, you can disable the installation of extensions on startup of Aidbox by setting the environment variable `AIDBOX_INSTALL_PG_EXTENSIONS` to `false`.  |
|
0 commit comments