Skip to content

Commit

Permalink
suppress diff on encryption key name if the database instance is a re…
Browse files Browse the repository at this point in the history
…plica (#5824) (#4130)

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Mar 17, 2022
1 parent 32cbf05 commit c3ee405
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/5824.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
sql: fixed bug where permadiff of `encryption_key_name` would show on `google_sql_database_instance` for replica instances.
```
17 changes: 14 additions & 3 deletions google-beta/resource_sql_database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ var (
}
)

func diffSuppressSqlReplicaKeyName(k, old, new string, d *schema.ResourceData) bool {
if d.Get("replica_configuration") != nil {
// This is a replica and the config value must be null, but the API will
// return the key name of the master instance, so we'll suppress this diff
return true
}

return false
}

func resourceSqlDatabaseInstance() *schema.Resource {
return &schema.Resource{
Create: resourceSqlDatabaseInstanceCreate,
Expand Down Expand Up @@ -436,9 +446,10 @@ settings.backup_configuration.binary_log_enabled are both set to true.`,
},

"encryption_key_name": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Type: schema.TypeString,
Optional: true,
DiffSuppressFunc: diffSuppressSqlReplicaKeyName,
ForceNew: true,
},

"root_password": {
Expand Down

0 comments on commit c3ee405

Please sign in to comment.