Skip to content

feat: module and example to create compute policies#226

Open
steven-muschler wants to merge 4 commits intodatabricks:mainfrom
steven-muschler:main
Open

feat: module and example to create compute policies#226
steven-muschler wants to merge 4 commits intodatabricks:mainfrom
steven-muschler:main

Conversation

@steven-muschler
Copy link

Adding in TF module and example that demonstrates how to create compute policies using policy families and allow for team specific overrides

@steven-muschler steven-muschler requested review from a team as code owners February 3, 2026 01:34
Comment on lines 7 to 8
policy_key = "personal-vm"
policy_family_id = "personal-vm"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need both if they are the same?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexott let me put in a better example for this scenario. The reason these are separate because DLT/SDP does not have a policy family, but requires specific policy elements like cluster_type

policy_family_id = "power-user"
group_assignments = ["groupB"]
service_principal_assignments = []
policy_overrides = "{\"autotermination_minutes\":{\"type\":\"fixed\",\"value\":60,\"hidden\": true}}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexott there's an issue I've run into before on this where the TF does not handle the object typing well. If we set the override type to an optional empty object, TF will type it based on the first one it sees in the variable files if we deploy more than one of the same resource. I'm open to other ideas, but something I've struggled with when working with one of our customers.

Comment on lines +20 to +34
cluster_policy_defaults = (
{
"personal-vm-dev" = merge(local.autotermination, local.required_tags, local.dev_runtimes)
"personal-vm-prod" = merge(local.autotermination, local.required_tags, local.prod_runtimes)
"shared-compute-dev" = merge(local.autotermination, local.required_tags, local.dev_runtimes)
"shared-compute-prod" = merge(local.autotermination, local.required_tags, local.prod_runtimes)
"power-user-dev" = merge(local.autotermination, local.required_tags, local.dev_runtimes)
"power-user-prod" = merge(local.autotermination, local.required_tags, local.prod_runtimes)
"job-cluster-dev" = merge(local.job_cluster_types, local.required_tags, local.dev_runtimes)
"job-cluster-prod" = merge(local.job_cluster_types, local.required_tags, local.prod_runtimes)
"sdp-cluster-dev" = merge(local.sdp_cluster_types, local.required_tags, local.dev_runtimes)
"sdp-cluster-prod" = merge(local.sdp_cluster_types, local.required_tags, local.prod_runtimes)
}
)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be very useful to provide more information about these built-in policy definitions

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a longer description to the module README

}

dynamic "access_control" {
for_each = toset(var.service_principal_assignments)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add variable for users as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can, though I've intentionally not done that as I don't believe that's a great pattern to encourage. Will change though if you feel it's important. LMK. Thanks!

Description for all variables
Remove alias as only one provider is used in this example
Show example of when policy_key and policy_family_id are different
@alexott alexott requested a review from Copilot February 4, 2026 14:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a Terraform module for creating Databricks cluster policies based on policy families, with support for environment-specific configurations and team-level customization. The implementation provides a reusable framework for managing compute policies across different teams and environments.

Changes:

  • Added a new Terraform module cluster-policy-from-policy-family that creates cluster policies with configurable overrides
  • Implemented JSON-based policy configurations for different environments (dev/prod), runtimes (standard/ML), and cluster types
  • Created an example configuration demonstrating multi-team policy deployment with team-specific overrides

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
modules/cluster-policy-from-policy-family/variables.tf Defines input variables for team, environment, policy version, and override configurations
modules/cluster-policy-from-policy-family/provider.tf Configures required Databricks provider
modules/cluster-policy-from-policy-family/outputs.tf Exposes the created policy ID
modules/cluster-policy-from-policy-family/cluster-policies.tf Main module logic that merges policy configurations and creates resources
modules/cluster-policy-from-policy-family/cluster_policy_json/*.json JSON configuration files for various policy components
modules/cluster-policy-from-policy-family/README.md Module documentation
modules/cluster-policy-from-policy-family/Makefile Build targets for documentation generation
examples/cluster-policies/*.tf Example implementation showing multi-team usage
examples/cluster-policies/example.tfvars Sample variable values for the example
examples/cluster-policies/README.md Example documentation
examples/cluster-policies/Makefile Build targets for example documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants