Skip to content
11 changes: 8 additions & 3 deletions bundle/direct/dresources/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,22 @@ var loadConfigs = sync.OnceValues(func() (*Config, *Config) {

for _, name := range names {
dst, resourceType := handWritten, strings.TrimSuffix(path.Base(name), ymlSuffix)
isGenerated := false
if trimmed, ok := strings.CutSuffix(resourceType, generatedSuffix); ok {
dst, resourceType = generated, trimmed
dst, resourceType, isGenerated = generated, trimmed, true
}

data, err := configFS.ReadFile(name)
if err != nil {
panic(err)
}

var rc ResourceLifecycleConfig
if err := yaml.Unmarshal(data, &rc); err != nil {
var fpc FieldPolicyConfig
if err := yaml.Unmarshal(data, &fpc); err != nil {
panic(fmt.Errorf("%s: %w", name, err))
}
rc, err := fpc.Lower(isGenerated)
if err != nil {
panic(fmt.Errorf("%s: %w", name, err))
}

Expand Down
26 changes: 9 additions & 17 deletions bundle/direct/dresources/configs/alerts.generated.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 26 additions & 52 deletions bundle/direct/dresources/configs/apps.generated.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 8 additions & 20 deletions bundle/direct/dresources/configs/apps.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
provided_id_fields:
- field: name
reason: id_field
backend_defaults:
# Backend sets it "MEDIUM" when not specified in the config
- field: compute_size
# Backend enables token forwarding and reports true even when the config omits it,
# so an omitted field would otherwise plan an update on every deploy. An explicit
# value in the config still diffs normally.
- field: forward_user_access_token
# lifecycle.started is derived from remote compute status in RemapState, so the
# remote side always has a value. When the user omits lifecycle from config,
# both old and new are nil and backend_defaults correctly skips the remote value.
# When the user explicitly sets lifecycle.started, old/new are non-nil and normal
# drift detection applies (e.g. detecting out-of-band stop).
- field: lifecycle
- field: lifecycle.started
ignore_remote_changes:
- field: space # This field is not yet supported by Update APIs but exposed in the API spec. TODO: fix when update APIs supports it.
reason: managed
fields:
name: [id]
compute_size: [backend_default]
forward_user_access_token: [backend_default]
lifecycle: [backend_default]
lifecycle.started: [backend_default]
space:
ignore_remote: managed
25 changes: 7 additions & 18 deletions bundle/direct/dresources/configs/catalogs.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
recreate_on_changes:
- field: storage_root
reason: immutable
- field: connection_name
reason: immutable
- field: provider_name
reason: immutable
- field: share_name
reason: immutable
normalize_slash:
fields:
# UC strips a trailing slash from storage_root on create. The TF provider
# suppresses the same slash-only drift on this field (ucDirectoryPathSlashOnlySuppressDiff):
# https://github.com/databricks/terraform-provider-databricks/blob/main/catalog/resource_catalog.go
- field: storage_root
reason: uc_strips_trailing_slash
updatable_id_fields:
- field: name
reason: id_changes
backend_defaults:
# UC auto-populates unity.catalog.managed.<format>.defaults.* keys after create.
- field: properties['unity.catalog.managed.*.defaults.*']
storage_root: [immutable, trim_slash]
connection_name: [immutable]
provider_name: [immutable]
share_name: [immutable]
name: [renameable_id]
properties['unity.catalog.managed.*.defaults.*']: [backend_default]
4 changes: 2 additions & 2 deletions bundle/direct/dresources/configs/cluster_policies.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
backend_defaults:
fields:
# A policy authored with policy_family_id and no definition gets its definition
# computed from the policy family by the backend and returned on read. Config
# leaves definition empty, so old/new are nil and backend_defaults skips the
# server-computed remote value; without this every deploy sees drift and re-Edits.
- field: definition
definition: [backend_default]
57 changes: 16 additions & 41 deletions bundle/direct/dresources/configs/clusters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,28 @@
# acceptance/bundle/resources/jobs/cluster_policy (fixed_addition, default_flag).
# https://github.com/databricks/cli/issues/5179
# https://github.com/databricks/cli/issues/6512
ignore_remote_additions:
- when_set: policy_id

ignore_remote_changes:
remote_additions_when: policy_id
fields:
# https://github.com/databricks/terraform-provider-databricks/blob/4eba541abe1a9f50993ea7b9dd83874207e224a1/clusters/resource_cluster.go#L361-L363
# s.SchemaPath("aws_attributes").SetSuppressDiff()
# s.SchemaPath("azure_attributes").SetSuppressDiff()
# s.SchemaPath("gcp_attributes").SetSuppressDiff()
- field: aws_attributes
reason: managed
- field: azure_attributes
reason: managed
- field: gcp_attributes
reason: managed
backend_defaults:
aws_attributes:
ignore_remote: managed
azure_attributes:
ignore_remote: managed
gcp_attributes:
ignore_remote: managed
# lifecycle.started is derived from remote cluster state in RemapState, so the
# remote side always has a value. When the user omits lifecycle from config,
# both old and new are nil and backend_defaults correctly skips the remote value.
# When the user explicitly sets lifecycle.started, old/new are non-nil and normal
# drift detection applies (e.g. detecting out-of-band terminate).
- field: lifecycle
- field: lifecycle.started
# https://github.com/databricks/terraform-provider-databricks/blob/4eba541abe1a9f50993ea7b9dd83874207e224a1/clusters/resource_cluster.go#L331
# s.SchemaPath("enable_elastic_disk").SetComputed()
- field: enable_elastic_disk

# https://github.com/databricks/terraform-provider-databricks/blob/4eba541abe1a9f50993ea7b9dd83874207e224a1/clusters/resource_cluster.go#L332
# s.SchemaPath("enable_local_disk_encryption").SetComputed()
- field: enable_local_disk_encryption

# https://github.com/databricks/terraform-provider-databricks/blob/4eba541abe1a9f50993ea7b9dd83874207e224a1/clusters/resource_cluster.go#L333
# s.SchemaPath("node_type_id").SetComputed()
- field: node_type_id

# https://github.com/databricks/terraform-provider-databricks/blob/4eba541abe1a9f50993ea7b9dd83874207e224a1/clusters/resource_cluster.go#L334
# s.SchemaPath("driver_node_type_id").SetComputed()
- field: driver_node_type_id

# https://github.com/databricks/terraform-provider-databricks/blob/4eba541abe1a9f50993ea7b9dd83874207e224a1/clusters/resource_cluster.go#L335
# s.SchemaPath("driver_instance_pool_id").SetComputed()
- field: driver_instance_pool_id

# Terraform currently does not do this, but it is a field with backend default.
# See https://github.com/databricks/cli/issues/4418
- field: single_user_name

# We have custom handler for this in cluster.go
# https://github.com/databricks/terraform-provider-databricks/blob/4eba541abe1a9f50993ea7b9dd83874207e224a1/clusters/resource_cluster.go#L109-L118
# DataSecurityModeDiffSuppressFunc: suppress when old != "" && new == ""
#- field: data_security_mode
lifecycle: [backend_default]
lifecycle.started: [backend_default]
enable_elastic_disk: [backend_default]
enable_local_disk_encryption: [backend_default]
node_type_id: [backend_default]
driver_node_type_id: [backend_default]
driver_instance_pool_id: [backend_default]
single_user_name: [backend_default]
22 changes: 7 additions & 15 deletions bundle/direct/dresources/configs/dashboards.generated.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 8 additions & 13 deletions bundle/direct/dresources/configs/dashboards.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
ignore_remote_changes:
fields:
# "serialized_dashboard" locally and remotely will have different contents
# We only need to rely on etag here, and can skip this field for diff computation.
- field: serialized_dashboard
reason: etag_based

# "serialized_dashboard" holds inlined dashboard JSON that is never read back
# from state, so we persist only its content hash.
serialized_dashboard:
ignore_remote: etag_based
hashed: true
# "dataset_catalog" and "dataset_schema" are write-only fields that are not returned by the server.
# They will always differ between local config (which has values) and remote state (which has empty strings).
- field: dataset_catalog
reason: input_only
- field: dataset_schema
reason: input_only

# "serialized_dashboard" holds inlined dashboard JSON that is never read back
# from state, so we persist only its content hash.
hashed_fields:
- serialized_dashboard
dataset_catalog: [input_only]
dataset_schema: [input_only]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions bundle/direct/dresources/configs/database_catalogs.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
provided_id_fields:
- field: name
reason: id_field
# The Database API has no UpdateDatabaseCatalog endpoint (the generated SDK
# method is a stub that returns 501 NOT_IMPLEMENTED), so this resource
# implements no DoUpdate and every settable field must recreate. The
# complementary ignore_remote_changes block in database_catalogs.generated.yml
# handles the read side (create_database_if_not_exists is input-only, uid is
# output-only) so no-op deploys stay idempotent.
recreate_on_changes:
- reason: immutable
action: immutable
fields:
name: [id]
Loading
Loading