Skip to content

Commit 0f0fe0b

Browse files
authored
Merge pull request #249 from dbt-labs/release-0.2.25
2 parents c128bd5 + 49997cd commit 0f0fe0b

File tree

6 files changed

+429
-112
lines changed

6 files changed

+429
-112
lines changed

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [Unreleased](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.24...HEAD)
5+
## [Unreleased](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.25...HEAD)
6+
7+
## [0.2.25](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.24...v0.2.25)
8+
9+
## Changes
10+
11+
- Enable OAuth configuration for Databricks connections + update docs accordingly
612

713
## [0.2.24](https://github.com/dbt-labs/terraform-provider-dbtcloud/compare/v0.2.23...v0.2.24)
814

docs/resources/connection.md

+31-24
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ For BigQuery, due to the list of fields being very different, you can use the `d
2323
// legacy names will be removed from 0.3 onwards
2424
2525
resource "dbtcloud_connection" "databricks" {
26-
project_id = dbtcloud_project.dbt_project.id
27-
type = "adapter"
28-
name = "Databricks"
29-
database = "" // currenyly need to be empty for databricks
30-
host_name = "my-databricks-host.cloud.databricks.com"
31-
http_path = "/my/path"
32-
catalog = "moo"
26+
project_id = dbtcloud_project.dbt_project.id
27+
type = "adapter"
28+
name = "Databricks"
29+
database = "" // currenyly need to be empty for databricks
30+
host_name = "my-databricks-host.cloud.databricks.com"
31+
http_path = "/my/path"
32+
catalog = "moo"
33+
// add the following for OAuth
34+
oauth_client_id = "yourclientid"
35+
oauth_client_secret = "yourclientsecret"
3336
}
3437
3538
resource "dbtcloud_connection" "redshift" {
@@ -42,13 +45,17 @@ resource "dbtcloud_connection" "redshift" {
4245
}
4346
4447
resource "dbtcloud_connection" "snowflake" {
45-
project_id = dbtcloud_project.dbt_project.id
46-
type = "snowflake"
47-
name = "My Snowflake warehouse"
48-
account = "my-snowflake-account"
49-
database = "MY_DATABASE"
50-
role = "MY_ROLE"
51-
warehouse = "MY_WAREHOUSE"
48+
project_id = dbtcloud_project.dbt_project.id
49+
type = "snowflake"
50+
name = "My Snowflake warehouse"
51+
account = "my-snowflake-account"
52+
database = "MY_DATABASE"
53+
role = "MY_ROLE"
54+
warehouse = "MY_WAREHOUSE"
55+
// add the following for OAuth
56+
oauth_client_id = "yourclientid"
57+
oauth_client_secret = "yourclientsecret"
58+
allow_sso = true
5259
}
5360
```
5461

@@ -64,24 +71,24 @@ resource "dbtcloud_connection" "snowflake" {
6471

6572
### Optional
6673

67-
- `account` (String) Account name for the connection
68-
- `allow_keep_alive` (Boolean) Whether or not the connection should allow client session keep alive
69-
- `allow_sso` (Boolean) Whether or not the connection should allow SSO
70-
- `catalog` (String) Catalog name if Unity Catalog is enabled in your Databricks workspace
74+
- `account` (String) Account name for the connection (for Snowflake)
75+
- `allow_keep_alive` (Boolean) Whether or not the connection should allow client session keep alive (for Snowflake)
76+
- `allow_sso` (Boolean) Whether or not the connection should allow SSO (for Snowflake)
77+
- `catalog` (String) Catalog name if Unity Catalog is enabled in your Databricks workspace (for Databricks)
7178
- `host_name` (String) Host name for the connection, including Databricks cluster
72-
- `http_path` (String) The HTTP path of the Databricks cluster or SQL warehouse
79+
- `http_path` (String) The HTTP path of the Databricks cluster or SQL warehouse (for Databricks)
7380
- `is_active` (Boolean) Whether the connection is active
74-
- `oauth_client_id` (String) OAuth client identifier
75-
- `oauth_client_secret` (String) OAuth client secret
81+
- `oauth_client_id` (String) OAuth client identifier (for Snowflake and Databricks)
82+
- `oauth_client_secret` (String) OAuth client secret (for Snowflake and Databricks)
7683
- `port` (Number) Port number to connect via
7784
- `private_link_endpoint_id` (String) The ID of the PrivateLink connection. This ID can be found using the `privatelink_endpoint` data source
78-
- `role` (String) Role name for the connection
85+
- `role` (String) Role name for the connection (for Snowflake)
7986
- `tunnel_enabled` (Boolean) Whether or not tunneling should be enabled on your database connection
80-
- `warehouse` (String) Warehouse name for the connection
87+
- `warehouse` (String) Warehouse name for the connection (for Snowflake)
8188

8289
### Read-Only
8390

84-
- `adapter_id` (Number) Adapter id created for the Databricks connection
91+
- `adapter_id` (Number) Adapter id created for the Databricks connection (for Databricks)
8592
- `connection_id` (Number) Connection Identifier
8693
- `id` (String) The ID of this resource.
8794

examples/resources/dbtcloud_connection/resource.tf

+21-14
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
// legacy names will be removed from 0.3 onwards
44

55
resource "dbtcloud_connection" "databricks" {
6-
project_id = dbtcloud_project.dbt_project.id
7-
type = "adapter"
8-
name = "Databricks"
9-
database = "" // currenyly need to be empty for databricks
10-
host_name = "my-databricks-host.cloud.databricks.com"
11-
http_path = "/my/path"
12-
catalog = "moo"
6+
project_id = dbtcloud_project.dbt_project.id
7+
type = "adapter"
8+
name = "Databricks"
9+
database = "" // currenyly need to be empty for databricks
10+
host_name = "my-databricks-host.cloud.databricks.com"
11+
http_path = "/my/path"
12+
catalog = "moo"
13+
// add the following for OAuth
14+
oauth_client_id = "yourclientid"
15+
oauth_client_secret = "yourclientsecret"
1316
}
1417

1518
resource "dbtcloud_connection" "redshift" {
@@ -22,11 +25,15 @@ resource "dbtcloud_connection" "redshift" {
2225
}
2326

2427
resource "dbtcloud_connection" "snowflake" {
25-
project_id = dbtcloud_project.dbt_project.id
26-
type = "snowflake"
27-
name = "My Snowflake warehouse"
28-
account = "my-snowflake-account"
29-
database = "MY_DATABASE"
30-
role = "MY_ROLE"
31-
warehouse = "MY_WAREHOUSE"
28+
project_id = dbtcloud_project.dbt_project.id
29+
type = "snowflake"
30+
name = "My Snowflake warehouse"
31+
account = "my-snowflake-account"
32+
database = "MY_DATABASE"
33+
role = "MY_ROLE"
34+
warehouse = "MY_WAREHOUSE"
35+
// add the following for OAuth
36+
oauth_client_id = "yourclientid"
37+
oauth_client_secret = "yourclientsecret"
38+
allow_sso = true
3239
}

pkg/dbt_cloud/connection.go

+38-5
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ func (c *Client) CreateConnection(
122122
hostName,
123123
httpPath,
124124
catalog,
125+
oAuthClientID,
126+
oAuthClientSecret,
125127
)
126128
} else {
127129
connectionDetails.Account = account
@@ -185,7 +187,8 @@ func (c *Client) CreateConnection(
185187
return nil, err
186188
}
187189

188-
if (oAuthClientID != "") && (oAuthClientSecret != "") {
190+
// those are secrets and not given back by the API
191+
if (oAuthClientID != "") && (oAuthClientSecret != "") && (connectionType != "adapter") {
189192
connectionResponse.Data.Details.OAuthClientID = oAuthClientID
190193
connectionResponse.Data.Details.OAuthClientSecret = oAuthClientSecret
191194
}
@@ -277,6 +280,8 @@ func GetDatabricksConnectionDetails(
277280
hostName string,
278281
httpPath string,
279282
catalog string,
283+
clientID string,
284+
clientSecret string,
280285
) *AdapterCredentialDetails {
281286
noValidation := AdapterCredentialFieldMetadataValidation{
282287
Required: false,
@@ -321,11 +326,39 @@ func GetDatabricksConnectionDetails(
321326
Value: httpPath,
322327
}
323328

324-
fieldOrder := []string{"type", "host", "http_path"}
329+
clientIDMetadata := AdapterCredentialFieldMetadata{
330+
Label: "OAuth Client ID",
331+
Description: "Required to enable Databricks OAuth authentication for IDE developers.",
332+
Field_Type: "text",
333+
Encrypt: true,
334+
Overrideable: false,
335+
Validation: noValidation,
336+
}
337+
clientIDField := AdapterCredentialField{
338+
Metadata: clientIDMetadata,
339+
Value: clientID,
340+
}
341+
342+
clientSecretMetadata := AdapterCredentialFieldMetadata{
343+
Label: "OAuth Client Secret",
344+
Description: "Required to enable Databricks OAuth authentication for IDE developers.",
345+
Field_Type: "text",
346+
Encrypt: true,
347+
Overrideable: false,
348+
Validation: noValidation,
349+
}
350+
clientSecretField := AdapterCredentialField{
351+
Metadata: clientSecretMetadata,
352+
Value: clientSecret,
353+
}
354+
355+
fieldOrder := []string{"type", "host", "http_path", "client_id", "client_secret"}
325356
fields := map[string]AdapterCredentialField{
326-
"type": typeField,
327-
"host": hostField,
328-
"http_path": httpPathField,
357+
"type": typeField,
358+
"host": hostField,
359+
"http_path": httpPathField,
360+
"client_id": clientIDField,
361+
"client_secret": clientSecretField,
329362
}
330363

331364
if catalog != "" {

0 commit comments

Comments
 (0)