Skip to content

Commit 9d9d836

Browse files
authored
[Fix] Suppress more computed options for databricks_connection (#5015)
## Changes - Resolves #4992 ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] `make test` run locally - [x] using Go SDK - [x] has entry in `NEXT_CHANGELOG.md` file
1 parent bdfb990 commit 9d9d836

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

NEXT_CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
* Fix regression with `databricks_group` data source introduced by a recent change ([#4995](https://github.com/databricks/terraform-provider-databricks/pull/4995))
1414

15+
* Fix drift detection for `databricks_connection` with HTTP OAuth M2M
16+
1517
### Documentation
1618

1719
* Document `continuous.task_retry_mode` in `databricks_job` ([#4993](https://github.com/databricks/terraform-provider-databricks/pull/4993))

catalog/resource_connection.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ import (
1313
var sensitiveOptions = []string{"user", "password", "personalAccessToken", "access_token", "client_secret",
1414
"pem_private_key", "OAuthPvtKey", "GoogleServiceAccountKeyJson", "bearer_token"}
1515

16-
func suppressPemPrivateKeyExpiration(k, old, new string, d *schema.ResourceData) bool {
17-
if k == "options.pem_private_key_expiration_epoch_sec" {
18-
log.Printf("[INFO] Suppressing diff on %s", k)
19-
return true
16+
var computedOptions = []string{"pem_private_key_expiration_epoch_sec", "access_token_expiration"}
17+
18+
func suppressComputedFields(k, old, new string, d *schema.ResourceData) bool {
19+
for _, option := range computedOptions {
20+
if k == "options."+option {
21+
log.Printf("[INFO] Suppressing diff on %s", k)
22+
return true
23+
}
2024
}
2125
return false
2226
}
@@ -34,7 +38,7 @@ func ResourceConnection() common.Resource {
3438
for _, v := range []string{"read_only", "properties", "comment", "connection_type"} {
3539
common.CustomizeSchemaPath(m, v).SetForceNew()
3640
}
37-
common.CustomizeSchemaPath(m, "options").SetSensitive().SetCustomSuppressDiff(suppressPemPrivateKeyExpiration)
41+
common.CustomizeSchemaPath(m, "options").SetSensitive().SetCustomSuppressDiff(suppressComputedFields)
3842
common.CustomizeSchemaPath(m, "name").SetCustomSuppressDiff(common.EqualFoldDiffSuppress)
3943

4044
return m
@@ -136,7 +140,9 @@ func ResourceConnection() common.Resource {
136140
}
137141

138142
updateConnectionRequest.Owner = ""
139-
delete(updateConnectionRequest.Options, "pem_private_key_expiration_epoch_sec")
143+
for _, option := range computedOptions {
144+
delete(updateConnectionRequest.Options, option)
145+
}
140146
_, err = w.Connections.Update(ctx, updateConnectionRequest)
141147
if err != nil {
142148
if d.HasChange("owner") {

0 commit comments

Comments
 (0)