Skip to content

Commit be88625

Browse files
Fix for desired_auto_created_endpoints incorrect update (#15720) (#11119)
[upstream:41a39ce69b8dafa59f8322b0753ca20b264e4916] Signed-off-by: Modular Magician <[email protected]>
1 parent b7ffcce commit be88625

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

.changelog/15720.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
memorystore: fixed an issue where a permadiff on `desired_auto_created_endpoints` caused the `google_memorystore_instance` resource to recreated.
3+
```

google-beta/services/memorystore/resource_memorystore_instance.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ import (
5454
"google.golang.org/api/googleapi"
5555
)
5656

57+
func memorystoreInstancedDesiredAutoConnectionsDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
58+
// Suppress diff wis to handle an edge case where desired_auto_created_endpoints in addtion to desired_psc_auto_connections are both set with same values
59+
// this is due to how the api reponds when mode is set to CLUSTER_DISABLED and desired_psc_auto_connections is set.
60+
log.Printf("[DEBUG] desired_auto_created_endpoints is set in state but not in config, supressing force new recreate")
61+
62+
oldAuto, newAuto := d.GetChange("desired_auto_created_endpoints")
63+
64+
if reflect.DeepEqual(oldAuto, newAuto) && !tpgresource.IsEmptyValue(reflect.ValueOf(oldAuto)) && !tpgresource.IsEmptyValue(reflect.ValueOf(newAuto)) {
65+
return true
66+
}
67+
68+
return false
69+
}
70+
5771
var (
5872
_ = bytes.Clone
5973
_ = context.WithCancel
@@ -998,10 +1012,11 @@ projects/{project_id}/global/networks/{network_id}.`,
9981012
ConflictsWith: []string{},
9991013
},
10001014
"desired_auto_created_endpoints": {
1001-
Type: schema.TypeList,
1002-
Optional: true,
1003-
ForceNew: true,
1004-
Description: `Immutable. User inputs for the auto-created endpoints connections.`,
1015+
Type: schema.TypeList,
1016+
Optional: true,
1017+
ForceNew: true,
1018+
DiffSuppressFunc: memorystoreInstancedDesiredAutoConnectionsDiffSuppress,
1019+
Description: `Immutable. User inputs for the auto-created endpoints connections.`,
10051020
Elem: &schema.Resource{
10061021
Schema: map[string]*schema.Schema{
10071022
"network": {

0 commit comments

Comments
 (0)