Skip to content

Commit b38d795

Browse files
authored
[Doc] Document management of permissions of databricks_budget_policy resource (#4561)
## Changes <!-- Summary of your changes that are easy to understand --> Resolves #4555 ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] relevant change in `docs/` folder
1 parent de416c9 commit b38d795

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

NEXT_CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
### Documentation
1010

11+
* Document management of permissions of `databricks_budget_policy` resource ([#4561](https://github.com/databricks/terraform-provider-databricks/pull/4561))
12+
1113
### Exporter
1214

1315
### Internal Changes

docs/resources/access_control_rule_set.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,57 @@ resource "databricks_access_control_rule_set" "account_rule_set" {
212212
}
213213
```
214214

215+
## Budget policy usage
216+
217+
Access to [budget policies](budget_policy.md) could be controlled with this resource:
218+
219+
```hcl
220+
locals {
221+
account_id = "00000000-0000-0000-0000-000000000000"
222+
}
223+
224+
// account level group
225+
data "databricks_group" "ds" {
226+
display_name = "Data Science"
227+
}
228+
229+
data "databricks_user" "john" {
230+
user_name = "[email protected]"
231+
}
232+
233+
resource "databricks_budget_policy" "this" {
234+
policy_name = "data-science-budget-policy"
235+
custom_tags = [{
236+
key = "mykey"
237+
value = "myvalue"
238+
}]
239+
}
240+
241+
resource "databricks_access_control_rule_set" "budget_policy_usage" {
242+
name = "accounts/${local.account_id}/budgetPolicies/${databricks_budget_policy.this.policy_id}/ruleSets/default"
243+
244+
// user john is the manager of this budget policy
245+
grant_rules {
246+
principals = [data.databricks_user.john.acl_principal_id]
247+
role = "roles/budgetPolicy.manager"
248+
}
249+
250+
// group data science is the user of the given budget policy
251+
grant_rules {
252+
principals = [data.databricks_group.ds.acl_principal_id]
253+
role = "roles/budgetPolicy.user"
254+
}
255+
}
256+
```
257+
258+
215259
## Argument Reference
216260

217261
* `name` - (Required) Unique identifier of a rule set. The name determines the resource to which the rule set applies. Currently, only default rule sets are supported. The following rule set formats are supported:
218262
* `accounts/{account_id}/servicePrincipals/{service_principal_application_id}/ruleSets/default`
219263
* `accounts/{account_id}/groups/{group_id}/ruleSets/default`
220264
* `accounts/{account_id}/ruleSets/default`
265+
* `accounts/{account_id}/budgetPolicies/{budget_policy_id}/ruleSets/default`
221266

222267
* `grant_rules` - (Required) The access control rules to be granted by this rule set, consisting of a set of principals and roles to be granted to them.
223268

@@ -238,11 +283,13 @@ grant_rules {
238283

239284
Arguments of the `grant_rules` block are:
240285

241-
* `role` - (Required) Role to be granted. The supported roles are listed below. For more information about these roles, refer to [service principal roles](https://docs.databricks.com/security/auth-authz/access-control/service-principal-acl.html#service-principal-roles), [group roles](https://docs.databricks.com/en/administration-guide/users-groups/groups.html#manage-roles-on-an-account-group-using-the-workspace-admin-settings-page) or [marketplace roles](https://docs.databricks.com/en/marketplace/get-started-provider.html#assign-the-marketplace-admin-role).
286+
* `role` - (Required) Role to be granted. The supported roles are listed below. For more information about these roles, refer to [service principal roles](https://docs.databricks.com/security/auth-authz/access-control/service-principal-acl.html#service-principal-roles), [group roles](https://docs.databricks.com/en/administration-guide/users-groups/groups.html#manage-roles-on-an-account-group-using-the-workspace-admin-settings-page), [marketplace roles](https://docs.databricks.com/en/marketplace/get-started-provider.html#assign-the-marketplace-admin-role) or [budget policy permissions](https://docs.databricks.com/aws/en/admin/usage/budget-policies#manage-budget-policy-permissions).
242287
* `roles/servicePrincipal.manager` - Manager of a service principal.
243288
* `roles/servicePrincipal.user` - User of a service principal.
244289
* `roles/group.manager` - Manager of a group.
245290
* `roles/marketplace.admin` - Admin of marketplace.
291+
* `roles/budgetPolicy.manager` - Manager of a budget policy.
292+
* `roles/budgetPolicy.user` - User of a budget policy.
246293
* `principals` - (Required) a list of principals who are granted a role. The following format is supported:
247294
* `users/{username}` (also exposed as `acl_principal_id` attribute of `databricks_user` resource).
248295
* `groups/{groupname}` (also exposed as `acl_principal_id` attribute of `databricks_group` resource).

docs/resources/budget_policy.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ subcategory: "FinOps"
55

66
Administrators can use budget policies to ensure that the correct tags appear automatically on serverless resources without depending on users to attach tags manually, allowing for customized cost reporting and chargebacks. Budget policies consist of tags that are applied to any serverless compute activity incurred by a user assigned to the policy. The tags are logged in your billing records, allowing you to attribute serverless usage to specific budgets.
77

8-
-> **Note** This resource can only be used with an account-level provider!
8+
-> This resource can only be used with an account-level provider!
99

1010

1111
## Example Usage
@@ -23,19 +23,24 @@ resource "databricks_budget_policy" "this" {
2323
## Argument Reference
2424

2525
The following arguments are available:
26+
2627
* `policy_name` - (Required) The name of the policy. Must be unique among active policies. Can contain only characters from the ISO 8859-1 (latin1) set.
2728
* `custom_tags` - (Optional) A list of tags defined by the customer. At most 20 entries are allowed per policy.
2829

2930
### custom_tags Configuration Block
31+
3032
* `key` - The key of the tag. - Must be unique among all custom tags of the same policy. Cannot be “budget-policy-name”, “budget-policy-id” or "budget-policy-resolution-result" as these tags are preserved.
3133
* `value` - The value of the tag.
3234

33-
3435
## Attribute Reference
3536

3637
In addition to all arguments above, the following attribute is exported:
38+
3739
* `policy_id` - ID of the budget policy
3840

41+
## Access Control
42+
43+
* [databricks_access_control_rule_set](access_control_rule_set.md) can control which groups or individual users can manage or use the given budget policy.
3944

4045
## Import
4146

0 commit comments

Comments
 (0)