Skip to content

Commit 8fa03d6

Browse files
nkvuongalexott
andauthored
[Documentation] Recommend OAuth instead of PAT (#4787)
## Changes - Recommend OAuth instead of PAT ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] relevant change in `docs/` folder --------- Co-authored-by: Alex Ott <[email protected]>
1 parent 13533c5 commit 8fa03d6

File tree

6 files changed

+16
-64
lines changed

6 files changed

+16
-64
lines changed

NEXT_CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* auto `zone_id` can only be used for fleet node types in `databricks_instance_pool` resource ([#4782](https://github.com/databricks/terraform-provider-databricks/pull/4782)).
1515
* Document `tags` attribute in `databricks_pipeline` resource ([#4783](https://github.com/databricks/terraform-provider-databricks/pull/4783)).
1616

17+
* Recommend OAuth instead of PAT in guides ([#4787](https://github.com/databricks/terraform-provider-databricks/pull/4787))
18+
1719
### Exporter
1820

1921
### Internal Changes

docs/guides/aws-workspace.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,20 +278,11 @@ resource "databricks_mws_workspaces" "this" {
278278
credentials_id = databricks_mws_credentials.this.credentials_id
279279
storage_configuration_id = databricks_mws_storage_configurations.this.storage_configuration_id
280280
network_id = databricks_mws_networks.this.network_id
281-
282-
token {
283-
comment = "Terraform"
284-
}
285281
}
286282
287283
output "databricks_host" {
288284
value = databricks_mws_workspaces.this.workspace_url
289285
}
290-
291-
output "databricks_token" {
292-
value = databricks_mws_workspaces.this.token[0].token_value
293-
sensitive = true
294-
}
295286
```
296287

297288
### Data resources and Authentication is not configured errors
@@ -310,12 +301,13 @@ In [the next step](workspace-management.md), please use the following configurat
310301

311302
```hcl
312303
provider "databricks" {
313-
host = module.e2.workspace_url
314-
token = module.e2.token_value
304+
host = module.e2.workspace_url
305+
client_id = var.client_id
306+
client_secret = var.client_secret
315307
}
316308
```
317309

318-
We assume that you have a terraform module in your project that creates a workspace (using [Databricks Workspace](#databricks-workspace) section) and you named it as `e2` while calling it in the **main.tf** file of your terraform project. And `workspace_url` and `token_value` are the output attributes of that module. This provider configuration will allow you to use the generated token to authenticate to the created workspace during workspace creation.
310+
We assume that you have a terraform module in your project that creates a workspace (using [Databricks Workspace](#databricks-workspace) section) and you named it as `e2` while calling it in the **main.tf** file of your terraform project and `workspace_url` is the output attribute of that module. This provider configuration will allow you to authenticate to the created workspace after workspace creation.
319311

320312
### Credentials validation checks errors
321313

docs/guides/gcp-private-service-connect-workspace.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,13 @@ resource "databricks_mws_workspaces" "this" {
125125
connectivity_type = "PRIVATE_NODE_PUBLIC_MASTER"
126126
master_ip_range = "10.3.0.0/28"
127127
}
128-
129-
token {
130-
comment = "Terraform"
131-
}
132-
133128
# this makes sure that the NAT is created for outbound traffic before creating the workspace
134129
depends_on = [google_compute_router_nat.nat]
135130
}
136131
137132
output "databricks_host" {
138133
value = databricks_mws_workspaces.this.workspace_url
139134
}
140-
141-
output "databricks_token" {
142-
value = databricks_mws_workspaces.this.token[0].token_value
143-
sensitive = true
144-
}
145135
```
146136

147137
### Data resources and Authentication is not configured errors

docs/guides/gcp-workspace.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,22 +225,13 @@ resource "databricks_mws_workspaces" "this" {
225225
226226
network_id = databricks_mws_networks.this.network_id
227227
228-
token {
229-
comment = "Terraform"
230-
}
231-
232228
# this makes sure that the NAT is created for outbound traffic before creating the workspace
233229
depends_on = [google_compute_router_nat.nat]
234230
}
235231
236232
output "databricks_host" {
237233
value = databricks_mws_workspaces.this.workspace_url
238234
}
239-
240-
output "databricks_token" {
241-
value = databricks_mws_workspaces.this.token[0].token_value
242-
sensitive = true
243-
}
244235
```
245236

246237
-> The `gke_config` argument and the `gke_cluster_service_ip_range` and `gke_pod_service_ip_range` arguments in `gcp_managed_network_config` are now deprecated and no longer supported. Omit these when creating workspaces in the future. If you have already created a workspace using these fields, it is safe to remove them from your Terraform template.
@@ -261,12 +252,13 @@ In [the next step](workspace-management.md), please use the following configurat
261252

262253
```hcl
263254
provider "databricks" {
264-
host = module.dbx_gcp.workspace_url
265-
token = module.dbx_gcp.token_value
255+
host = module.dbx_gcp.workspace_url
256+
client_id = var.client_id
257+
client_secret = var.client_secret
266258
}
267259
```
268260

269-
We assume that you have a terraform module in your project that creates a workspace (using [Databricks Workspace](#creating-a-databricks-workspace) section), and you named it as `dbx_gcp` while calling it in the **main.tf** file of your terraform project. And `workspace_url` and `token_value` are the output attributes of that module. This provider configuration will allow you to use the generated token to authenticate to the created workspace during workspace creation.
261+
We assume that you have a terraform module in your project that creates a workspace (using [Databricks Workspace](#creating-a-databricks-workspace) section), and you named it as `dbx_gcp` while calling it in the **main.tf** file of your terraform project and `workspace_url` is the output attribute of that module. This provider configuration will allow you to authenticate to the created workspace after workspace creation.
270262

271263
### More than one authorization method configured error
272264

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ resource "databricks_group" "cluster_admin" {
262262

263263
### Authenticating with hostname and token
264264

265+
~> Databricks strongly recommends using OAuth instead of PATs for user account client authentication and authorization due to the improved security OAuth has
266+
265267
You can use `host` and `token` parameters to supply credentials to the workspace. When environment variables are preferred, then you can specify `DATABRICKS_HOST` and `DATABRICKS_TOKEN` instead. Environment variables are the second most recommended way of configuring this provider.
266268

267269
``` hcl

docs/resources/mws_workspaces.md

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ resource "databricks_mws_workspaces" "this" {
8585
credentials_id = databricks_mws_credentials.this.credentials_id
8686
storage_configuration_id = databricks_mws_storage_configurations.this.storage_configuration_id
8787
network_id = databricks_mws_networks.this.network_id
88-
89-
token {}
90-
}
91-
92-
output "databricks_token" {
93-
value = databricks_mws_workspaces.this.token[0].token_value
94-
sensitive = true
9588
}
9689
```
9790

@@ -201,20 +194,13 @@ resource "databricks_mws_workspaces" "this" {
201194
credentials_id = databricks_mws_credentials.this.credentials_id
202195
storage_configuration_id = databricks_mws_storage_configurations.this.storage_configuration_id
203196
204-
token {}
205-
206197
# Optional Custom Tags
207198
custom_tags = {
208199
209200
"SoldToCode" = "1234"
210201
211202
}
212203
}
213-
214-
output "databricks_token" {
215-
value = databricks_mws_workspaces.this.token[0].token_value
216-
sensitive = true
217-
}
218204
```
219205

220206
In order to create a [Databricks Workspace that leverages AWS PrivateLink](https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html) please ensure that you have read and understood the [Enable Private Link](https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html) documentation and then customise the example above with the relevant examples from [mws_vpc_endpoint](mws_vpc_endpoint.md), [mws_private_access_settings](mws_private_access_settings.md) and [mws_networks](mws_networks.md).
@@ -264,13 +250,6 @@ resource "databricks_mws_workspaces" "this" {
264250
}
265251
266252
network_id = databricks_mws_networks.this.network_id
267-
268-
token {}
269-
}
270-
271-
output "databricks_token" {
272-
value = databricks_mws_workspaces.this.token[0].token_value
273-
sensitive = true
274253
}
275254
```
276255

@@ -304,13 +283,6 @@ resource "databricks_mws_workspaces" "this" {
304283
project_id = data.google_client_config.current.project
305284
}
306285
}
307-
308-
token {}
309-
}
310-
311-
output "databricks_token" {
312-
value = databricks_mws_workspaces.this.token[0].token_value
313-
sensitive = true
314286
}
315287
```
316288

@@ -338,9 +310,11 @@ The following arguments are available:
338310
* `pricing_tier` - (Optional) - The pricing tier of the workspace.
339311
* `compute_mode` - (Optional) - The compute mode for the workspace. When unset, a classic workspace is created, and both `credentials_id` and `storage_configuration_id` must be specified. When set to `SERVERLESS`, the resulting workspace is a serverless workspace, and `credentials_id` and `storage_configuration_id` must not be set. The only allowed value for this is `SERVERLESS`. Changing this field requires recreation of the workspace.
340312

341-
### token block
313+
~> Databricks strongly recommends using OAuth instead of PATs for user account client authentication and authorization due to the improved security
314+
315+
### token block (legacy)
342316

343-
You can specify a `token` block in the body of the workspace resource, so that Terraform manages the refresh of the PAT token for the deployment user. The other option is to create [databricks_obo_token](obo_token.md), though it requires Premium or Enterprise plan enabled as well as more complex setup. Token block exposes `token_value`, that holds sensitive PAT token and optionally it can accept two arguments:
317+
You can specify a `token` block in the body of the workspace resource, so that Terraform manages the refresh of the PAT token for the deployment user. Token block exposes `token_value`, that holds sensitive PAT token and optionally it can accept two arguments:
344318

345319
-> Tokens managed by `token {}` block are recreated when expired.
346320

0 commit comments

Comments
 (0)