Skip to content

Commit 5d43af4

Browse files
authored
fix(lakebase): Update instructions for manually obtaining LAKEBASE_ENDPOINT (#121)
1 parent fdd28d8 commit 5d43af4

8 files changed

Lines changed: 63 additions & 59 deletions

File tree

apps/dev-playground/.env.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ NODE_ENV='development'
66
OTEL_EXPORTER_OTLP_ENDPOINT='http://localhost:4318'
77
OTEL_RESOURCE_ATTRIBUTES='service.sample_attribute=dev'
88
OTEL_SERVICE_NAME='dev-playground'
9-
LAKEBASE_ENDPOINT='' # Format: projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id}
9+
LAKEBASE_ENDPOINT='' # Run: databricks postgres list-endpoints projects/{project-id}/branches/{branch-id} — use the `name` field from the output
1010
PGHOST=
1111
PGUSER=
1212
PGDATABASE=databricks_postgres

docs/docs/api/appkit/Function.generateDatabaseCredential.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ https://docs.databricks.com/aws/en/oltp/projects/authentication
2929
## Examples
3030

3131
```typescript
32-
// Format: projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id}
33-
// Note: Use actual IDs from Databricks (project-id is a UUID)
32+
// Use the `name` field from the Databricks CLI output:
33+
// `databricks postgres list-endpoints projects/{project-id}/branches/{branch-id}`
3434
const credential = await generateDatabaseCredential(workspaceClient, {
35-
endpoint: "projects/6bef4151-4b5d-4147-b4d0-c2f4fd5b40db/branches/br-sparkling-tree-y17uj7fn/endpoints/ep-restless-pine-y1ldaht0"
35+
endpoint: "projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-identifier}"
3636
});
3737

3838
// Use credential.token as password
@@ -44,9 +44,10 @@ const conn = await pg.connect({
4444
```
4545

4646
```typescript
47-
// Format: projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id}
47+
// Use the `name` field from the Databricks CLI output:
48+
// `databricks postgres list-endpoints projects/{project-id}/branches/{branch-id}`
4849
const credential = await generateDatabaseCredential(workspaceClient, {
49-
endpoint: "projects/6bef4151-4b5d-4147-b4d0-c2f4fd5b40db/branches/br-sparkling-tree-y17uj7fn/endpoints/ep-restless-pine-y1ldaht0",
50+
endpoint: "projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-identifier}",
5051
claims: [{
5152
permission_set: RequestedClaimsPermissionSet.READ_ONLY,
5253
resources: [{ table_name: "catalog.schema.users" }]

docs/docs/api/appkit/Interface.GenerateDatabaseCredentialRequest.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,14 @@ When specified, the token will only grant access to the specified tables.
3232
endpoint: string;
3333
```
3434

35-
Endpoint resource path with IDs assigned by Databricks.
36-
37-
All segments are IDs from Databricks (not names you create):
38-
- project-id: UUID format (e.g., `a1b2c3d4-e5f6-4789-a012-b3c4d5e6f789`)
39-
- branch-id: Identifier from Databricks (e.g., `main`, `dev`)
40-
- endpoint-id: Identifier from Databricks (e.g., `primary`, `analytics`)
41-
42-
Format: `projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id}`
43-
44-
**Important:** Copy from Databricks Lakebase UI - do not construct manually.
35+
Endpoint resource path. Retrieve using the Databricks CLI:
36+
```
37+
databricks postgres list-endpoints projects/{project-id}/branches/{branch-id}
38+
```
39+
Use the `name` field from the output.
4540

4641
#### Example
4742

4843
```ts
49-
"projects/6bef4151-4b5d-4147-b4d0-c2f4fd5b40db/branches/br-sparkling-tree-y17uj7fn/endpoints/ep-restless-pine-y1ldaht0"
44+
"projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-identifier}"
5045
```

docs/docs/api/appkit/Interface.LakebasePoolConfig.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,19 @@ optional endpoint: string;
2626

2727
Endpoint resource path for OAuth token generation.
2828

29-
All segments are IDs assigned by Databricks (not names you create):
30-
- project-id: UUID format (e.g., `a1b2c3d4-e5f6-4789-a012-b3c4d5e6f789`)
31-
- branch-id: Identifier from Databricks (e.g., `main`, `dev`)
32-
- endpoint-id: Identifier from Databricks (e.g., `primary`, `analytics`)
33-
34-
Format: `projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id}`
29+
Retrieve the value using the Databricks CLI:
30+
```
31+
databricks postgres list-endpoints projects/{project-id}/branches/{branch-id}
32+
```
33+
Use the `name` field from the output.
3534

3635
Required for OAuth authentication (unless password is provided)
3736
Can also be set via LAKEBASE_ENDPOINT environment variable
3837

3938
#### Example
4039

4140
```ts
42-
"projects/6bef4151-4b5d-4147-b4d0-c2f4fd5b40db/branches/br-sparkling-tree-y17uj7fn/endpoints/ep-restless-pine-y1ldaht0"
41+
"projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-identifier}"
4342
```
4443

4544
***

packages/lakebase/README.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,25 @@ Set the following environment variables:
3131
```bash
3232
export PGHOST=your-lakebase-host.databricks.com
3333
export PGDATABASE=your_database_name
34-
export LAKEBASE_ENDPOINT=projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id}
35-
export PGUSER=your-service-principal-id
34+
export LAKEBASE_ENDPOINT=projects/6bef4151-4b5d-4147-b4d0-c2f4fd5b40db/branches/br-broad-pine-y12n6gnv/endpoints/ep-summer-frost-y131l3vx
35+
export PGUSER=your_user # optionally, defaults to DATABRICKS_CLIENT_ID
3636
export PGSSLMODE=require
3737
```
3838

39+
To find your `LAKEBASE_ENDPOINT`, run the Databricks CLI and use the `name` field from the output:
40+
41+
```bash
42+
databricks postgres list-endpoints projects/{project-id}/branches/{branch-id}
43+
```
44+
45+
You can obtain the Project ID and Branch ID from the Lakebase Autoscaling UI, like the "Branch Overview" page. (Project list -> Project dashboard -> Branch overview). When using the driver as a part of Databricks Apps, the `LAKEBASE_ENDPOINT` is automatically injected using `fromValue`:
46+
47+
```yaml
48+
env:
49+
- name: LAKEBASE_ENDPOINT
50+
valueFrom: database # Lakebase Autoscaling database resource name
51+
```
52+
3953
Then use the driver:
4054
4155
```typescript
@@ -52,11 +66,11 @@ console.log(result.rows);
5266
import { createLakebasePool } from "@databricks/lakebase";
5367

5468
const pool = createLakebasePool({
55-
host: "your-lakebase-host.databricks.com",
56-
database: "your_database_name",
69+
host: "your-lakebase-host.databricks.com", // defaults to PGHOST environment variable
70+
database: "your_database_name", // defaults to PGDATABASE environment variable
5771
endpoint:
58-
"projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id}",
59-
user: "service-principal-id", // Optional, defaults to DATABRICKS_CLIENT_ID
72+
"projects/6bef4151-4b5d-4147-b4d0-c2f4fd5b40db/branches/br-broad-pine-y12n6gnv/endpoints/ep-summer-frost-y131l3vx", // defaults to LAKEBASE_ENDPOINT environment variable
73+
user: "user_id", // Optional, defaults to PGUSER or DATABRICKS_CLIENT_ID
6074
max: 10, // Connection pool size
6175
});
6276
```
@@ -66,10 +80,10 @@ const pool = createLakebasePool({
6680
The driver supports Databricks authentication via:
6781

6882
1. **Default auth chain** (`.databrickscfg`, environment variables)
69-
2. **Service principal** (`DATABRICKS_CLIENT_ID` + `DATABRICKS_CLIENT_SECRET`)
70-
3. **OAuth tokens** (via Databricks SDK)
83+
2. **OAuth tokens** (via Databricks SDK)
84+
3. **Native Postgres password authentication**
7185

72-
See [Databricks authentication docs](https://docs.databricks.com/en/dev-tools/auth/index.html) for configuration.
86+
See [Databricks authentication docs](https://docs.databricks.com/en/dev-tools/auth/index.html) or [Lakebase Autoscaling authentication docs](https://docs.databricks.com/aws/en/oltp/projects/authentication#overview) for more information.
7387

7488
## Configuration
7589

packages/lakebase/src/credentials.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import type {
1919
*
2020
* @example
2121
* ```typescript
22-
* // Format: projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id}
23-
* // Note: Use actual IDs from Databricks (project-id is a UUID)
22+
* // Use the `name` field from the Databricks CLI output:
23+
* // `databricks postgres list-endpoints projects/{project-id}/branches/{branch-id}`
2424
* const credential = await generateDatabaseCredential(workspaceClient, {
25-
* endpoint: "projects/6bef4151-4b5d-4147-b4d0-c2f4fd5b40db/branches/br-sparkling-tree-y17uj7fn/endpoints/ep-restless-pine-y1ldaht0"
25+
* endpoint: "projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-identifier}"
2626
* });
2727
*
2828
* // Use credential.token as password
@@ -35,9 +35,10 @@ import type {
3535
*
3636
* @example With UC table permissions
3737
* ```typescript
38-
* // Format: projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id}
38+
* // Use the `name` field from the Databricks CLI output:
39+
* // `databricks postgres list-endpoints projects/{project-id}/branches/{branch-id}`
3940
* const credential = await generateDatabaseCredential(workspaceClient, {
40-
* endpoint: "projects/6bef4151-4b5d-4147-b4d0-c2f4fd5b40db/branches/br-sparkling-tree-y17uj7fn/endpoints/ep-restless-pine-y1ldaht0",
41+
* endpoint: "projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-identifier}",
4142
* claims: [{
4243
* permission_set: RequestedClaimsPermissionSet.READ_ONLY,
4344
* resources: [{ table_name: "catalog.schema.users" }]

packages/lakebase/src/pool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ import type { LakebasePoolConfig } from "./types";
3030
*
3131
* @example With explicit configuration
3232
* ```typescript
33-
* // Format: projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id}
34-
* // Note: Use actual IDs from Databricks (project-id is a UUID)
33+
* // Use the `name` field from the Databricks CLI output:
34+
* // `databricks postgres list-endpoints projects/{project-id}/branches/{branch-id}`
3535
* const pool = createLakebasePool({
36-
* endpoint: 'projects/6bef4151-4b5d-4147-b4d0-c2f4fd5b40db/branches/br-sparkling-tree-y17uj7fn/endpoints/ep-restless-pine-y1ldaht0',
36+
* endpoint: 'projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-identifier}',
3737
* host: 'ep-abc.databricks.com',
3838
* database: 'databricks_postgres',
3939
* user: 'service-principal-id'

packages/lakebase/src/types.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,16 @@ export interface LakebasePoolConfig extends PoolConfig {
6060
/**
6161
* Endpoint resource path for OAuth token generation.
6262
*
63-
* All segments are IDs assigned by Databricks (not names you create):
64-
* - project-id: UUID format (e.g., `a1b2c3d4-e5f6-4789-a012-b3c4d5e6f789`)
65-
* - branch-id: Identifier from Databricks (e.g., `main`, `dev`)
66-
* - endpoint-id: Identifier from Databricks (e.g., `primary`, `analytics`)
67-
*
68-
* Format: `projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id}`
63+
* Retrieve the value using the Databricks CLI:
64+
* ```
65+
* databricks postgres list-endpoints projects/{project-id}/branches/{branch-id}
66+
* ```
67+
* Use the `name` field from the output.
6968
*
7069
* Required for OAuth authentication (unless password is provided)
7170
* Can also be set via LAKEBASE_ENDPOINT environment variable
7271
*
73-
* @example "projects/6bef4151-4b5d-4147-b4d0-c2f4fd5b40db/branches/br-sparkling-tree-y17uj7fn/endpoints/ep-restless-pine-y1ldaht0"
72+
* @example "projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-identifier}"
7473
*/
7574
endpoint?: string;
7675

@@ -184,18 +183,13 @@ export interface RequestedClaims {
184183
*/
185184
export interface GenerateDatabaseCredentialRequest {
186185
/**
187-
* Endpoint resource path with IDs assigned by Databricks.
188-
*
189-
* All segments are IDs from Databricks (not names you create):
190-
* - project-id: UUID format (e.g., `a1b2c3d4-e5f6-4789-a012-b3c4d5e6f789`)
191-
* - branch-id: Identifier from Databricks (e.g., `main`, `dev`)
192-
* - endpoint-id: Identifier from Databricks (e.g., `primary`, `analytics`)
193-
*
194-
* Format: `projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-id}`
195-
*
196-
* **Important:** Copy from Databricks Lakebase UI - do not construct manually.
186+
* Endpoint resource path. Retrieve using the Databricks CLI:
187+
* ```
188+
* databricks postgres list-endpoints projects/{project-id}/branches/{branch-id}
189+
* ```
190+
* Use the `name` field from the output.
197191
*
198-
* @example "projects/6bef4151-4b5d-4147-b4d0-c2f4fd5b40db/branches/br-sparkling-tree-y17uj7fn/endpoints/ep-restless-pine-y1ldaht0"
192+
* @example "projects/{project-id}/branches/{branch-id}/endpoints/{endpoint-identifier}"
199193
*/
200194
endpoint: string;
201195

0 commit comments

Comments
 (0)