Skip to content

Commit 0b5e4a3

Browse files
authored
Fix secret scope permissions migration from Terraform to Direct engine (#4866)
## Summary - Fix `bundle deployment migrate` for bundles with secret scopes to prevent phantom drift on `secret_scopes.*.permissions` after migration from Terraform to Direct engine. - Handle `databricks_secret_acl` in `ParseResourcesState`: multiple ACL resources per scope are mapped to a single `.permissions` state entry with the scope name as ID, similar to how `databricks_permissions` and `databricks_grants` are handled. - Expose resources.secret_scopes.foo.permissions as a separate entry in terraform JSON plan as well to match direct engine. ## Test plan - Re-enable the previously excluded secret scope migration acceptance tests. - New invariant test config for secret scope with ACLs.
1 parent 33d1007 commit 0b5e4a3

24 files changed

Lines changed: 247 additions & 34 deletions

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* engine/direct: Fix unwanted recreation of secret scopes when scope_backend_type is not set ([#4834](https://github.com/databricks/cli/pull/4834))
1515
* engine/direct: Fix bind and unbind for non-Terraform resources ([#4850](https://github.com/databricks/cli/pull/4850))
1616
* engine/direct: Fix deploying removed principals ([#4824](https://github.com/databricks/cli/pull/4824))
17+
* engine/direct: Fix secret scope permissions migration from Terraform to Direct engine ([#4866](https://github.com/databricks/cli/pull/4866))
1718

1819
### Dependency updates
1920

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
bundle:
2+
name: test-bundle-$UNIQUE_NAME
3+
4+
resources:
5+
secret_scopes:
6+
foo:
7+
name: test-scope-$UNIQUE_NAME
8+
backend_type: DATABRICKS
9+
permissions:
10+
- level: READ
11+
group_name: users
12+
- level: WRITE
13+
group_name: admins

acceptance/bundle/invariant/continue_293/out.test.toml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acceptance/bundle/invariant/migrate/out.test.toml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acceptance/bundle/invariant/migrate/test.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
EnvMatrixExclude.no_catalog = ["INPUT_CONFIG=catalog.yml.tmpl"]
33
EnvMatrixExclude.no_external_location = ["INPUT_CONFIG=external_location.yml.tmpl"]
44

5-
# Unexpected action='create' for resources.secret_scopes.foo.permissions
6-
EnvMatrixExclude.no_secret_scope = ["INPUT_CONFIG=secret_scope.yml.tmpl"]
7-
EnvMatrixExclude.no_secret_scope2 = ["INPUT_CONFIG=secret_scope_default_backend_type.yml.tmpl"]
8-
95
# Cross-resource permission references (e.g. ${resources.jobs.job_b.permissions[0].level})
106
# don't work in terraform mode: the terraform interpolator converts the path to
117
# ${databricks_job.job_b.permissions[0].level}, but Terraform's databricks_job resource

acceptance/bundle/invariant/no_drift/out.test.toml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acceptance/bundle/invariant/test.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ EnvMatrix.INPUT_CONFIG = [
4949
"schema_with_grants.yml.tmpl",
5050
"secret_scope.yml.tmpl",
5151
"secret_scope_default_backend_type.yml.tmpl",
52+
"secret_scope_with_permissions.yml.tmpl",
5253
"synced_database_table.yml.tmpl",
5354
"volume.yml.tmpl",
5455
]

acceptance/bundle/resources/secret_scopes/basic/out.plan1.terraform.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"plan": {
44
"resources.secret_scopes.my_scope": {
55
"action": "create"
6+
},
7+
"resources.secret_scopes.my_scope.permissions": {
8+
"action": "create"
69
}
710
}
811
}

acceptance/bundle/resources/secret_scopes/basic/out.plan2.terraform.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"plan": {
44
"resources.secret_scopes.my_scope": {
55
"action": "recreate"
6+
},
7+
"resources.secret_scopes.my_scope.permissions": {
8+
"action": "recreate"
69
}
710
}
811
}

acceptance/bundle/resources/secret_scopes/basic/out.plan_verify_no_drift.terraform.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"plan": {
44
"resources.secret_scopes.my_scope": {
55
"action": "skip"
6+
},
7+
"resources.secret_scopes.my_scope.permissions": {
8+
"action": "skip"
69
}
710
}
811
}

0 commit comments

Comments
 (0)