Skip to content

Commit 1ce6c68

Browse files
Suppress the diff for false value of force_attach field (#14057) (#22954)
[upstream:78268de211c5b3834cf4307222bab65c9069b926] Signed-off-by: Modular Magician <[email protected]>
1 parent 9f110be commit 1ce6c68

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

.changelog/14057.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
compute: fixed forced instance recreation when adding a `attached_disk` with `force_attach` being `false` to `google_compute_instance`
3+
```

google/services/compute/resource_compute_instance.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func IpCidrRangeDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
6666
}
6767

6868
func DisksForceAttachDiffSuppress(_, old, new string, _ *schema.ResourceData) bool {
69+
if (new == "false" && old == "") || (new == "" && old == "false") {
70+
return true
71+
}
72+
6973
if new == old {
7074
return true
7175
}

google/services/compute/resource_compute_instance_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ func TestDisksForceAttachDiffSuppress(t *testing.T) {
132132
New: "false",
133133
ExpectDiffSuppress: true,
134134
},
135+
"force_attach changed false from empty": {
136+
Old: "",
137+
New: "false",
138+
ExpectDiffSuppress: true,
139+
},
140+
"force_attach changed empty from false": {
141+
Old: "false",
142+
New: "",
143+
ExpectDiffSuppress: true,
144+
},
135145
}
136146

137147
for tn, tc := range cases {

0 commit comments

Comments
 (0)