diff --git a/acceptance/bundle/resources/clusters/deploy/data_security_mode/out.direct.txt b/acceptance/bundle/resources/clusters/deploy/data_security_mode/out.direct.txt deleted file mode 100644 index 207dddbf43..0000000000 --- a/acceptance/bundle/resources/clusters/deploy/data_security_mode/out.direct.txt +++ /dev/null @@ -1,12 +0,0 @@ - ->>> [CLI] bundle deploy -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... -Deploying resources... -Updating deployment state... -Deployment complete! - ->>> errcode [CLI] bundle deploy -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... -Deploying resources... -Updating deployment state... -Deployment complete! diff --git a/acceptance/bundle/resources/clusters/deploy/data_security_mode/out.plan.direct.txt b/acceptance/bundle/resources/clusters/deploy/data_security_mode/out.plan.direct.txt deleted file mode 100644 index 438db04e9e..0000000000 --- a/acceptance/bundle/resources/clusters/deploy/data_security_mode/out.plan.direct.txt +++ /dev/null @@ -1,5 +0,0 @@ - ->>> [CLI] bundle plan -update clusters.test_cluster - -Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged diff --git a/acceptance/bundle/resources/clusters/deploy/data_security_mode/out.plan.terraform.txt b/acceptance/bundle/resources/clusters/deploy/data_security_mode/out.plan.terraform.txt deleted file mode 100644 index f88b3379f3..0000000000 --- a/acceptance/bundle/resources/clusters/deploy/data_security_mode/out.plan.terraform.txt +++ /dev/null @@ -1,3 +0,0 @@ - ->>> [CLI] bundle plan -Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged diff --git a/acceptance/bundle/resources/clusters/deploy/data_security_mode/out.terraform.txt b/acceptance/bundle/resources/clusters/deploy/data_security_mode/out.terraform.txt deleted file mode 100644 index 207dddbf43..0000000000 --- a/acceptance/bundle/resources/clusters/deploy/data_security_mode/out.terraform.txt +++ /dev/null @@ -1,12 +0,0 @@ - ->>> [CLI] bundle deploy -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... -Deploying resources... -Updating deployment state... -Deployment complete! - ->>> errcode [CLI] bundle deploy -Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... -Deploying resources... -Updating deployment state... -Deployment complete! diff --git a/acceptance/bundle/resources/clusters/deploy/data_security_mode/output.txt b/acceptance/bundle/resources/clusters/deploy/data_security_mode/output.txt index df30d22ab0..00a60890fd 100644 --- a/acceptance/bundle/resources/clusters/deploy/data_security_mode/output.txt +++ b/acceptance/bundle/resources/clusters/deploy/data_security_mode/output.txt @@ -1,4 +1,19 @@ +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... +Deploying resources... +Updating deployment state... +Deployment complete! + +>>> [CLI] bundle plan +Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged + +>>> [CLI] bundle deploy +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... +Deploying resources... +Updating deployment state... +Deployment complete! + >>> [CLI] bundle destroy --auto-approve The following resources will be deleted: delete cluster test_cluster diff --git a/acceptance/bundle/resources/clusters/deploy/data_security_mode/script b/acceptance/bundle/resources/clusters/deploy/data_security_mode/script index 3bb6a77bed..43b1af4911 100644 --- a/acceptance/bundle/resources/clusters/deploy/data_security_mode/script +++ b/acceptance/bundle/resources/clusters/deploy/data_security_mode/script @@ -5,8 +5,6 @@ cleanup() { } trap cleanup EXIT -trace $CLI bundle deploy > out.$DATABRICKS_BUNDLE_ENGINE.txt 2>&1 - -trace $CLI bundle plan >> out.plan.$DATABRICKS_BUNDLE_ENGINE.txt 2>&1 - -trace errcode $CLI bundle deploy >> out.$DATABRICKS_BUNDLE_ENGINE.txt 2>&1 +trace $CLI bundle deploy +trace $CLI bundle plan +trace $CLI bundle deploy diff --git a/bundle/direct/dresources/cluster.go b/bundle/direct/dresources/cluster.go index edf8154cd1..23b6c892c1 100644 --- a/bundle/direct/dresources/cluster.go +++ b/bundle/direct/dresources/cluster.go @@ -119,13 +119,27 @@ func (r *ResourceCluster) DoDelete(ctx context.Context, id string) error { return r.client.Clusters.PermanentDeleteByClusterId(ctx, id) } -func (r *ResourceCluster) ClassifyChange(change structdiff.Change, remoteState *compute.ClusterDetails, _ bool) (deployplan.ActionType, error) { +func (r *ResourceCluster) ClassifyChange(change structdiff.Change, remoteState *compute.ClusterDetails, isLocal bool) (deployplan.ActionType, error) { + changedPath := change.Path.String() + if changedPath == "data_security_mode" && !isLocal { + // We do change skip here in the same way TF provider does suppress diff if the alias is used. + // https://github.com/databricks/terraform-provider-databricks/blob/main/clusters/resource_cluster.go#L109-L117 + if change.Old == compute.DataSecurityModeDataSecurityModeStandard && change.New == compute.DataSecurityModeUserIsolation { + return deployplan.ActionTypeSkip, nil + } + if change.Old == compute.DataSecurityModeDataSecurityModeDedicated && change.New == compute.DataSecurityModeSingleUser { + return deployplan.ActionTypeSkip, nil + } + if change.Old == compute.DataSecurityModeDataSecurityModeAuto && (change.New == compute.DataSecurityModeSingleUser || change.New == compute.DataSecurityModeUserIsolation) { + return deployplan.ActionTypeSkip, nil + } + } + // Always update if the cluster is not running. if remoteState.State != compute.StateRunning { return deployplan.ActionTypeUpdate, nil } - changedPath := change.Path.String() if changedPath == "num_workers" || strings.HasPrefix(changedPath, "autoscale") { return deployplan.ActionTypeResize, nil }