Skip to content

Commit 8064876

Browse files
authored
Improve docs for databricks_permissions and databricks_obo_token (#1462)
* Fix Terraform docs for databricks_permissions and OBO tokens
1 parent c268c41 commit 8064876

File tree

3 files changed

+48
-11
lines changed

3 files changed

+48
-11
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ go install honnef.co/go/tools/cmd/[email protected]
6666

6767
Installing `gotestsum`:
6868
```bash
69-
go get gotest.tools/gotestsum
69+
go install gotest.tools/gotestsum
7070
```
7171

7272
Installing `goimports`:
7373
```bash
74-
go get golang.org/x/tools/cmd/goimports
74+
go install golang.org/x/tools/cmd/goimports
7575
```
7676

7777
After this, you should be able to run `make coverage` to run the tests and see the coverage.

docs/resources/obo_token.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ This resource creates [On-Behalf-Of tokens](https://docs.databricks.com/administ
77

88
## Example Usage
99

10-
Creating a token for a narrowly-scoped service principal, that would be the only one (besides admins) allowed to use PAT token in this given workspace, keeping your automated deployment highly secure. Keep in mind that a given declaration of `databricks_permissions.token_usage` would remove permissions to use PAT tokens from the `users` group.
10+
Creating a token for a narrowly-scoped service principal, that would be the only one (besides admins) allowed to use PAT token in this given workspace, keeping your automated deployment highly secure.
11+
12+
-> **Note** A given declaration of `databricks_permissions.token_usage` would OVERWRITE permissions to use PAT tokens from any existing groups with token usage permissions such as the `users` group. To avoid this, be sure to include any desired groups in additional `access_control` blocks in the Terraform configuration file.
1113

1214
```hcl
1315
resource "databricks_service_principal" "this" {

docs/resources/permissions.md

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ subcategory: "Security"
44

55
# databricks_permissions Resource
66

7-
This resource allows you to generically manage [access control](https://docs.databricks.com/security/access-control/index.html) in Databricks workspace. It would guarantee that only _admins_, _authenticated principal_ and those declared within `access_control` blocks would have specified access. It is not possible to remove management rights from _admins_ group.
7+
This resource allows you to generically manage [access control](https://docs.databricks.com/security/access-control/index.html) in Databricks workspace. It would guarantee that only _admins_, _authenticated principal_ and those declared within `access_control` blocks would have specified access. It is not possible to remove management rights from _admins_ group.
8+
9+
-> **Note** Configuring this resource for an object will **OVERWRITE** any existing permissions of the same type unless imported, and changes made outside of Terraform will be reset unless the changes are also reflected in the configuration.
810

911
-> **Note** It is not possible to lower permissions for `admins` or your own user anywhere from `CAN_MANAGE` level, so Databricks Terraform Provider [removes](https://github.com/databricks/terraform-provider-databricks/blob/master/access/resource_permissions.go#L261-L271) those `access_control` blocks automatically.
1012

@@ -669,21 +671,31 @@ General Permissions API does not apply to access control for tables and they hav
669671
Initially in Unity Catalog all users have no access to data, which has to be later assigned through [databricks_grants](grants.md) resource.
670672

671673
## Argument Reference
674+
One type argument and at least one access control block argument are required.
672675

673-
Exactly one of the following attributes is required:
676+
### Type Argument
677+
Exactly one of the following arguments is required:
674678

675679
- `cluster_id` - [cluster](cluster.md) id
680+
- `cluster_policy_id` - [cluster policy](cluster_policy.md) id
681+
- `instance_pool_id` - [instance pool](instance_pool.md) id
676682
- `job_id` - [job](job.md) id
677-
- `directory_id` - [directory](notebook.md) id
678-
- `directory_path` - path of directory
683+
- `pipeline_id` - [pipeline](pipeline.md) id
679684
- `notebook_id` - ID of [notebook](notebook.md) within workspace
680685
- `notebook_path` - path of notebook
686+
- `directory_id` - [directory](notebook.md) id
687+
- `directory_path` - path of directory
681688
- `repo_id` - [repo](repo.md) id
682689
- `repo_path` - path of databricks repo directory(`/Repos/<username>/...`)
683-
- `cluster_policy_id` - [cluster policy](cluster_policy.md) id
684-
- `instance_pool_id` - [instance pool](instance_pool.md) id
690+
- `experiment_id` - [MLflow experiment](mlflow_experiment.md) id
691+
- `registered_model_id` - [MLflow registered model](mlflow_model.md) id
685692
- `authorization` - either [`tokens`](https://docs.databricks.com/administration-guide/access-control/tokens.html) or [`passwords`](https://docs.databricks.com/administration-guide/users-groups/single-sign-on/index.html#configure-password-permission).
693+
- `sql_endpoint_id` - [SQL endpoint](sql_endpoint.md) id
694+
- `sql_dashboard_id` - [SQL dashboard](sql_dashboard.md) id
695+
- `sql_query_id` - [SQL query](sql_query.md) id
696+
- `sql_alert_id` - [SQL alert](https://docs.databricks.com/sql/user/security/access-control/alert-acl.html) id
686697

698+
### Access Control Argument
687699
One or more `access_control` blocks are required to actually set the permission levels:
688700

689701
```hcl
@@ -693,13 +705,13 @@ access_control {
693705
}
694706
```
695707

696-
Attributes are:
708+
Arguments for the `access_control` block are:
697709

698710
-> **Note** It is not possible to lower permissions for `admins` or your own user anywhere from `CAN_MANAGE` level, so Databricks Terraform Provider [removes](https://github.com/databricks/terraform-provider-databricks/blob/master/access/resource_permissions.go#L261-L271) those `access_control` blocks automatically.
699711

700712
- `permission_level` - (Required) permission level according to specific resource. See examples above for the reference.
701713

702-
Exactly one of the below attributes is required:
714+
Exactly one of the below arguments is required:
703715
- `user_name` - (Optional) name of the [user](user.md).
704716
- `service_principal_name` - (Optional) Application ID of the [service_principal](service_principal.md#application_id).
705717
- `group_name` - (Optional) name of the [group](group.md). We recommend setting permissions on groups.
@@ -718,3 +730,26 @@ The resource permissions can be imported using the object id
718730
```bash
719731
$ terraform import databricks_permissions.this /<object type>/<object id>
720732
```
733+
734+
### Import Example
735+
Configuration file:
736+
```hcl
737+
resource "databricks_mlflow_model" "model" {
738+
name = "example_model"
739+
description = "MLflow registered model"
740+
}
741+
742+
resource "databricks_permissions" "model_usage" {
743+
registered_model_id = databricks_mlflow_model.model.registered_model_id
744+
745+
access_control {
746+
group_name = "users"
747+
permission_level = "CAN_READ"
748+
}
749+
}
750+
```
751+
752+
Import command:
753+
```bash
754+
$ terraform import databricks_permissions.model_usage /registered-models/<registered_model_id>
755+
```

0 commit comments

Comments
 (0)