From b092ec1a631f56b8700d8120e6f3df9fbb35d609 Mon Sep 17 00:00:00 2001 From: Jonathan Moss <2729151+jwmoss@users.noreply.github.com> Date: Mon, 7 Sep 2026 19:00:44 -0400 Subject: [PATCH] feat: extract the sql-warehouse resource module --- .gitattributes | 2 + .github/dependabot.yml | 44 +++++++++ .github/workflows/ci.yml | 91 ++++++++++++++++++ .gitignore | 11 +++ .pre-commit-config.yaml | 8 ++ .terraform-docs.yml | 15 +++ .terraform.lock.hcl | 17 ++++ .tflint.hcl | 4 + CHANGELOG.md | 7 ++ LICENSE | 202 +++++++++++++++++++++++++++++++++++++++ README.md | 201 +++++++++++++++++++++++++++++++++++++- main.tf | 47 +++++++++ outputs.tf | 14 +++ tests/module.tftest.hcl | 49 ++++++++++ variables.tf | 64 +++++++++++++ versions.tf | 10 ++ 16 files changed, 784 insertions(+), 2 deletions(-) create mode 100644 .gitattributes create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 .terraform-docs.yml create mode 100644 .terraform.lock.hcl create mode 100644 .tflint.hcl create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 main.tf create mode 100644 outputs.tf create mode 100644 tests/module.tftest.hcl create mode 100644 variables.tf create mode 100644 versions.tf diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..88d3805 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Markdown uses trailing spaces for line breaks. +*.md whitespace=-blank-at-eol diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..87e0bb3 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,44 @@ +version: 2 + +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + day: monday + time: "09:00" + timezone: America/New_York + cooldown: + default-days: 7 + groups: + github-actions: + patterns: + - "*" + + - package-ecosystem: pre-commit + directory: / + schedule: + interval: weekly + day: monday + time: "09:00" + timezone: America/New_York + cooldown: + default-days: 7 + groups: + hooks: + patterns: + - "*" + + - package-ecosystem: terraform + directory: / + schedule: + interval: weekly + day: monday + time: "09:00" + timezone: America/New_York + cooldown: + default-days: 7 + groups: + terraform: + patterns: + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f893002 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,91 @@ +name: ci + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + terraform: + name: fmt, validate, tflint, test + runs-on: ubuntu-latest + + steps: + - name: Check out the repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Check generated Terraform docs + uses: terraform-docs/gh-actions@6de6da0cefcc6b4b7a5cbea4d79d97060733093c # v1.4.1 + with: + config-file: .terraform-docs.yml + fail-on-diff: "true" + output-format: "" + output-method: "" + working-dir: . + + - name: Set up Terraform + uses: hashicorp/setup-terraform@dfe3c3f87815947d99a8997f908cb6525fc44e9e # v4.0.1 + with: + terraform_version: 1.16.1 + terraform_wrapper: false + + - name: Run pre-commit hooks + uses: j178/prek-action@4e14d07f9231acabce116ccfca13b13dd9755ece # v3.0.0 + env: + SKIP: terraform_docs + + - name: Set up tflint + uses: terraform-linters/setup-tflint@1cf010d3c7aef302051ccdb68c14c5dc2efa34ef # v6.3.1 + with: + tflint_version: v0.64.0 + + - name: Create the provider plugin cache + run: | + set -euo pipefail + mkdir -p "${RUNNER_TEMP}/terraform-plugin-cache" + echo "TF_PLUGIN_CACHE_DIR=${RUNNER_TEMP}/terraform-plugin-cache" >> "${GITHUB_ENV}" + + - name: Check formatting + run: terraform fmt -recursive -check -diff + + - name: Initialize + run: terraform init -backend=false -input=false -no-color -lockfile=readonly + + - name: Validate + run: terraform validate -no-color + + - name: Lint + run: | + set -euo pipefail + tflint --init + tflint --recursive + + - name: Test + run: terraform test -no-color + + - name: Test the minimum Databricks provider + run: | + set -euo pipefail + cp .terraform.lock.hcl "${RUNNER_TEMP}/provider.lock.hcl" + trap 'mv "${RUNNER_TEMP}/provider.lock.hcl" .terraform.lock.hcl; rm -f minimum_override.tf' EXIT + cat > minimum_override.tf <<'EOF' + terraform { + required_providers { + databricks = { + source = "databricks/databricks" + version = "= 1.128.0" + } + } + } + EOF + terraform init -backend=false -input=false -no-color -upgrade + terraform test -no-color diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f6582ca --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +.terraform/ +.terraform.lock.hcl +!/.terraform.lock.hcl +*.tfstate +*.tfstate.* +crash.log +override.tf +override.tf.json +*_override.tf +*_override.tf.json +.terraform.tfstate.lock.info diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..ffdc5f2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,8 @@ +repos: + - repo: https://github.com/antonbabenko/pre-commit-terraform + rev: v1.109.1 + hooks: + - id: terraform_fmt + - id: terraform_docs + args: + - --args=--config=.terraform-docs.yml diff --git a/.terraform-docs.yml b/.terraform-docs.yml new file mode 100644 index 0000000..4254182 --- /dev/null +++ b/.terraform-docs.yml @@ -0,0 +1,15 @@ +formatter: markdown document + +sections: + hide: + - modules + +output: + file: README.md + mode: inject + +settings: + anchor: false + hide-empty: true + html: false + lockfile: false diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl new file mode 100644 index 0000000..25c8573 --- /dev/null +++ b/.terraform.lock.hcl @@ -0,0 +1,17 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/databricks/databricks" { + version = "1.130.0" + constraints = ">= 1.128.0, < 2.0.0" + hashes = [ + "h1:+EhOXfmgUCrqhU/TXKHSqoUxIhgwDhEu8y2C7ojL/fU=", + "h1:R4p+E9wHi7HvyloBcxPm61SW5P7l6FWw0ceOv6mrcTY=", + "zh:3f142a69dae3f963aa194f1825a04070847ca473fd4b738fc91e9effe528fc91", + "zh:6c77abaf3d7ec5e60cba9fad359b8435bf5d6e0349637dbe27457ae7a2edf6be", + "zh:71a0d965e4e0e5829c7b676bbf1173f63d9283b75d0a56b0f77e0ddd9ef12874", + "zh:9893b546e51097800f2755bd3a34d87d617692c774172b61ef05e822619e9d09", + "zh:ccf130738e6be4b219f68d51be2fbca9a8c6dd9ba04180156f9352de406141c1", + "zh:e6917f2b034e13fac2e9ca36557c7dfe9945c95a5cf6c5f0b851e06395e60895", + ] +} diff --git a/.tflint.hcl b/.tflint.hcl new file mode 100644 index 0000000..427121c --- /dev/null +++ b/.tflint.hcl @@ -0,0 +1,4 @@ +plugin "terraform" { + enabled = true + preset = "recommended" +} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..bcc1fe6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## 0.1.0 - 2026-09-07 + +- Extract the `warehouse` resource module from `536tech/workspace/databricks` version 0.1.1. +- Preserve its inputs, outputs, resource addresses, and provider requirements. +- Add independent Registry releases and CI checks. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a47c87c --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2026 536tech + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 77fe19e..c490458 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,199 @@ -# terraform-databricks-sql-warehouse -Terraform module for a Databricks sql warehouse. +# Databricks sql warehouse Terraform module + +One SQL warehouse. + +Creates one SQL warehouse and, when `permissions` is not empty, one `databricks_permissions` block on it. The module turns the `tags` map into `tags { custom_tags { ... } }` blocks. + +## Resources + +- `databricks_sql_endpoint.this` +- `databricks_permissions.this[0]` (count = 1 only when `permissions` is not empty) + +The resource addresses above are part of the DataTF import contract. Do not rename them. + +## Usage + +```hcl +module "warehouse" { + source = "536tech/sql-warehouse/databricks" + version = "0.1.0" + + name = "Analytics WH" + cluster_size = "Small" + min_num_clusters = 1 + max_num_clusters = 3 + auto_stop_mins = 20 + warehouse_type = "PRO" + enable_photon = true + enable_serverless_compute = true + + tags = { + team = "analytics" + } + + permissions = [{ + permission_level = "CAN_USE" + group_name = "analysts" + }] +} +``` + +## Compatibility + +Configure the Databricks provider in the calling root with a workspace endpoint. +This resource module is also used by the +[workspace pattern module](https://registry.terraform.io/modules/536tech/workspace/databricks/latest). +Each repository has its own releases. Consumers select an exact tested module version. + +The resource addresses match the original workspace submodule in version 0.1.1. +To migrate a direct submodule call, change its source and version. Keep the module block name. +Run `terraform init` and require a plan with no resource changes. +DataTF exports continue to use the workspace pattern module and its existing import addresses. + +## Development + +Use Terraform 1.7 or later for the mock tests. The module supports Terraform 1.5 or later. + +```sh +prek install +terraform init -backend=false -lockfile=readonly +terraform validate +terraform test +tflint --recursive +prek run --all-files +``` + +CI tests the committed provider version and the minimum supported provider, 1.128.0. +The workspace pattern module checks the complete DataTF contract and its integration behavior. + +## License + +[Apache-2.0](LICENSE). + + +## Requirements + +The following requirements are needed by this module: + +- terraform (>= 1.5.0) + +- databricks (>= 1.128.0, < 2.0.0) + +## Providers + +The following providers are used by this module: + +- databricks (>= 1.128.0, < 2.0.0) + +## Resources + +The following resources are used by this module: + +- [databricks_permissions.this](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/permissions) (resource) +- [databricks_sql_endpoint.this](https://registry.terraform.io/providers/databricks/databricks/latest/docs/resources/sql_endpoint) (resource) + +## Required Inputs + +The following input variables are required: + +### auto\_stop\_mins + +Description: Minutes of inactivity before the warehouse stops. 0 disables auto stop. + +Type: `number` + +### cluster\_size + +Description: Warehouse size, for example 2X-Small, Small, or Medium. + +Type: `string` + +### enable\_photon + +Description: Run queries on the Photon engine. + +Type: `bool` + +### enable\_serverless\_compute + +Description: Run the warehouse on serverless compute. + +Type: `bool` + +### max\_num\_clusters + +Description: Maximum number of clusters the warehouse scales to. + +Type: `number` + +### min\_num\_clusters + +Description: Minimum number of clusters the warehouse runs. + +Type: `number` + +### name + +Description: SQL warehouse name. + +Type: `string` + +### warehouse\_type + +Description: Warehouse type: CLASSIC or PRO. + +Type: `string` + +## Optional Inputs + +The following input variables are optional (have default values): + +### permissions + +Description: Direct permissions on the warehouse. Each element names exactly one principal. + +Type: + +```hcl +list(object({ + permission_level = string + group_name = optional(string) + user_name = optional(string) + service_principal_name = optional(string) + })) +``` + +Default: `[]` + +### spot\_instance\_policy + +Description: Spot policy: COST\_OPTIMIZED or RELIABILITY\_OPTIMIZED. + +Type: `string` + +Default: `null` + +### tags + +Description: Custom tags applied to the warehouse. + +Type: `map(string)` + +Default: `null` + +## Outputs + +The following outputs are exported: + +### id + +Description: SQL warehouse id. + +### jdbc\_url + +Description: JDBC URL of the warehouse. + +### name + +Description: SQL warehouse name. + diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..8addb4a --- /dev/null +++ b/main.tf @@ -0,0 +1,47 @@ +locals { + tags = var.tags == null ? {} : var.tags +} + +resource "databricks_sql_endpoint" "this" { + name = var.name + cluster_size = var.cluster_size + min_num_clusters = var.min_num_clusters + max_num_clusters = var.max_num_clusters + auto_stop_mins = var.auto_stop_mins + warehouse_type = var.warehouse_type + enable_photon = var.enable_photon + enable_serverless_compute = var.enable_serverless_compute + spot_instance_policy = var.spot_instance_policy + + dynamic "tags" { + for_each = length(local.tags) > 0 ? [local.tags] : [] + + content { + dynamic "custom_tags" { + for_each = tags.value + + content { + key = custom_tags.key + value = custom_tags.value + } + } + } + } +} + +resource "databricks_permissions" "this" { + count = length(var.permissions) > 0 ? 1 : 0 + + sql_endpoint_id = databricks_sql_endpoint.this.id + + dynamic "access_control" { + for_each = var.permissions + + content { + permission_level = access_control.value.permission_level + group_name = access_control.value.group_name + user_name = access_control.value.user_name + service_principal_name = access_control.value.service_principal_name + } + } +} diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..3dd8e80 --- /dev/null +++ b/outputs.tf @@ -0,0 +1,14 @@ +output "id" { + description = "SQL warehouse id." + value = databricks_sql_endpoint.this.id +} + +output "name" { + description = "SQL warehouse name." + value = databricks_sql_endpoint.this.name +} + +output "jdbc_url" { + description = "JDBC URL of the warehouse." + value = databricks_sql_endpoint.this.jdbc_url +} diff --git a/tests/module.tftest.hcl b/tests/module.tftest.hcl new file mode 100644 index 0000000..c64cd7f --- /dev/null +++ b/tests/module.tftest.hcl @@ -0,0 +1,49 @@ +mock_provider "databricks" {} + +variables { + + name = "Analytics WH" + cluster_size = "Small" + min_num_clusters = 1 + max_num_clusters = 3 + auto_stop_mins = 20 + warehouse_type = "PRO" + enable_photon = true + enable_serverless_compute = true + + tags = { + team = "analytics" + } + + permissions = [{ + permission_level = "CAN_USE" + group_name = "analysts" + }] +} + +run "documented_example" { + command = apply + + assert { + condition = databricks_sql_endpoint.this.name == var.name + error_message = "The resource must preserve its configured name." + } + + assert { + condition = length(databricks_permissions.this) == 1 + error_message = "Configured access must have stable resource addresses." + } +} + +run "without_access" { + command = plan + + variables { + permissions = [] + } + + assert { + condition = length(databricks_permissions.this) == 0 + error_message = "Empty access must omit the access resources." + } +} diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..910144a --- /dev/null +++ b/variables.tf @@ -0,0 +1,64 @@ +variable "name" { + description = "SQL warehouse name." + type = string +} + +variable "cluster_size" { + description = "Warehouse size, for example 2X-Small, Small, or Medium." + type = string +} + +variable "min_num_clusters" { + description = "Minimum number of clusters the warehouse runs." + type = number +} + +variable "max_num_clusters" { + description = "Maximum number of clusters the warehouse scales to." + type = number +} + +variable "auto_stop_mins" { + description = "Minutes of inactivity before the warehouse stops. 0 disables auto stop." + type = number +} + +variable "warehouse_type" { + description = "Warehouse type: CLASSIC or PRO." + type = string +} + +variable "enable_photon" { + description = "Run queries on the Photon engine." + type = bool +} + +variable "enable_serverless_compute" { + description = "Run the warehouse on serverless compute." + type = bool +} + +variable "spot_instance_policy" { + description = "Spot policy: COST_OPTIMIZED or RELIABILITY_OPTIMIZED." + type = string + default = null +} + +variable "tags" { + description = "Custom tags applied to the warehouse." + type = map(string) + default = null +} + +variable "permissions" { + description = "Direct permissions on the warehouse. Each element names exactly one principal." + + type = list(object({ + permission_level = string + group_name = optional(string) + user_name = optional(string) + service_principal_name = optional(string) + })) + + default = [] +} diff --git a/versions.tf b/versions.tf new file mode 100644 index 0000000..ea4e802 --- /dev/null +++ b/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.5.0" + + required_providers { + databricks = { + source = "databricks/databricks" + version = ">= 1.128.0, < 2.0.0" + } + } +}