Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.0.1 - 2026-09-16

- Validate module inputs and access rules before provider API requests.
- Reject invalid permissions and conflicting settings without changing resource addresses.
- Preserve provider defaults for optional values.

## 1.0.0 - 2026-09-09

- Declare the module contract stable. The inputs, outputs, resource addresses, and provider
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The resource addresses above are part of the DataTF import contract. Do not rena
```hcl
module "schema" {
source = "536tech/schema/databricks"
version = "1.0.0"
version = "1.0.1"

catalog_name = "sales"
name = "bronze"
Expand Down Expand Up @@ -61,6 +61,19 @@ The workspace pattern module checks the complete DataTF contract and its integra

[Apache-2.0](LICENSE).

## Input safeguards

The module rejects blank required names and invalid access inputs during the plan.
Cross-input preconditions preserve the Terraform 1.5 minimum and existing resource addresses.
Provider and API checks still apply. These checks do not prove complete permission visibility.

Each grant needs one unique principal and at least one nonblank privilege.
The module does not freeze the Unity Catalog privilege list; the provider and API check supported privileges.
`databricks_grants` manages the complete direct grant set on the object.
Preserve the caller's required grants and review the plan before apply.
Empty grants omit the grant resource; they do not declare an empty authoritative grant set.
See [provider grant semantics](https://github.com/databricks/terraform-provider-databricks/blob/v1.130.0/docs/resources/grants.md).

<!-- BEGIN_TF_DOCS -->
## Requirements

Expand Down
32 changes: 32 additions & 0 deletions tests/module.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,35 @@ run "without_access" {
error_message = "Empty access must omit the access resources."
}
}

run "reject_blank_name" {
command = plan
variables {
name = " "
}
expect_failures = [var.name]
}

run "reject_blank_principal" {
command = plan
variables {
grants = [{ principal = " ", privileges = ["SELECT"] }]
}
expect_failures = [var.grants]
}

run "reject_empty_privileges" {
command = plan
variables {
grants = [{ principal = "readers", privileges = [] }]
}
expect_failures = [var.grants]
}

run "reject_duplicate_principal" {
command = plan
variables {
grants = [{ principal = "readers", privileges = ["SELECT"] }, { principal = "readers", privileges = ["MODIFY"] }]
}
expect_failures = [var.grants]
}
23 changes: 22 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
variable "catalog_name" {
description = "Name of the catalog that holds the schema."
type = string
nullable = false

validation {
condition = try(length(trimspace(var.catalog_name)) > 0, false)
error_message = "catalog_name must not be empty or blank."
}
}

variable "name" {
description = "Schema name."
type = string
nullable = false

validation {
condition = try(length(trimspace(var.name)) > 0, false)
error_message = "name must not be empty or blank."
}
}

variable "storage_root" {
Expand All @@ -26,7 +38,16 @@ variable "grants" {
principal = string
privileges = list(string)
}))
default = []
default = []
nullable = false

validation {
condition = try(alltrue([for grant in var.grants :
length(trimspace(grant.principal)) > 0 && length(grant.privileges) > 0 &&
alltrue([for privilege in grant.privileges : length(trimspace(privilege)) > 0])
]) && length(distinct([for grant in var.grants : grant.principal])) == length(var.grants), false)
error_message = "Each grant needs a unique nonblank principal and at least one nonblank privilege."
}
}

variable "force_destroy" {
Expand Down