Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Suppress options.pem_private_key_expiration_epoch_sec attribute for databricks_connection #4474

Merged
merged 7 commits into from
Feb 11, 2025
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
2 changes: 2 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

### Bug Fixes

* Suppress `options.pem_private_key_expiration_epoch_sec` attribute for databricks_connection ([#4474](https://github.com/databricks/terraform-provider-databricks/pull/4474)).

### Documentation

* Add an example for Databricks Apps permissions ([#4475](https://github.com/databricks/terraform-provider-databricks/pull/4475)).
Expand Down
13 changes: 12 additions & 1 deletion catalog/resource_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package catalog

import (
"context"
"log"

"github.com/databricks/databricks-sdk-go/service/catalog"
"github.com/databricks/terraform-provider-databricks/common"
Expand Down Expand Up @@ -34,12 +35,21 @@ type ConnectionInfo struct {
ReadOnly bool `json:"read_only,omitempty" tf:"force_new,computed"`
}

var sensitiveOptions = []string{"user", "password", "personalAccessToken", "access_token", "client_secret", "OAuthPvtKey", "GoogleServiceAccountKeyJson"}
var sensitiveOptions = []string{"user", "password", "personalAccessToken", "access_token", "client_secret", "pem_private_key", "OAuthPvtKey", "GoogleServiceAccountKeyJson"}

func suppressPemPrivateKeyExpiration(k, old, new string, d *schema.ResourceData) bool {
if k == "options.pem_private_key_expiration_epoch_sec" {
log.Printf("[INFO] Suppressing diff on %s", k)
return true
}
return false
}

func ResourceConnection() common.Resource {
s := common.StructToSchema(ConnectionInfo{},
func(m map[string]*schema.Schema) map[string]*schema.Schema {
m["name"].DiffSuppressFunc = common.EqualFoldDiffSuppress
m["options"].DiffSuppressFunc = suppressPemPrivateKeyExpiration
return m
})
pi := common.NewPairID("metastore_id", "name").Schema(
Expand Down Expand Up @@ -132,6 +142,7 @@ func ResourceConnection() common.Resource {
}

updateConnectionRequest.Owner = ""
delete(updateConnectionRequest.Options, "pem_private_key_expiration_epoch_sec")
_, err = w.Connections.Update(ctx, updateConnectionRequest)
if err != nil {
if d.HasChange("owner") {
Expand Down
Loading