@@ -190,3 +190,98 @@ resource "google_filestore_instance" "instance" {
190
190
}
191
191
` , name )
192
192
}
193
+
194
+ func TestAccFilestoreInstance_deletionProtection_update (t * testing.T ) {
195
+ t .Parallel ()
196
+
197
+ name := fmt .Sprintf ("tf-test-%d" , acctest .RandInt (t ))
198
+ location := "us-central1-a"
199
+ tier := "ZONAL"
200
+
201
+ deletionProtection := true
202
+
203
+ acctest .VcrTest (t , resource.TestCase {
204
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
205
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
206
+ CheckDestroy : testAccCheckFilestoreInstanceDestroyProducer (t ),
207
+ Steps : []resource.TestStep {
208
+ {
209
+ Config : testAccFilestoreInstance_deletionProtection_create (name , location , tier ),
210
+ },
211
+ {
212
+ ResourceName : "google_filestore_instance.instance" ,
213
+ ImportState : true ,
214
+ ImportStateVerify : true ,
215
+ ImportStateVerifyIgnore : []string {"zone" },
216
+ },
217
+ {
218
+ Config : testAccFilestoreInstance_deletionProtection_update (name , location , tier , deletionProtection ),
219
+ },
220
+ {
221
+ ResourceName : "google_filestore_instance.instance" ,
222
+ ImportState : true ,
223
+ ImportStateVerify : true ,
224
+ ImportStateVerifyIgnore : []string {"zone" },
225
+ },
226
+ {
227
+ Config : testAccFilestoreInstance_deletionProtection_update (name , location , tier , ! deletionProtection ),
228
+ },
229
+ {
230
+ ResourceName : "google_filestore_instance.instance" ,
231
+ ImportState : true ,
232
+ ImportStateVerify : true ,
233
+ ImportStateVerifyIgnore : []string {"zone" },
234
+ },
235
+ },
236
+ })
237
+ }
238
+
239
+ func testAccFilestoreInstance_deletionProtection_create (name , location , tier string ) string {
240
+ return fmt .Sprintf (`
241
+ resource "google_filestore_instance" "instance" {
242
+ name = "%s"
243
+ zone = "%s"
244
+ tier = "%s"
245
+ description = "An instance created during testing."
246
+
247
+ file_shares {
248
+ capacity_gb = 1024
249
+ name = "share"
250
+ }
251
+
252
+ networks {
253
+ network = "default"
254
+ modes = ["MODE_IPV4"]
255
+ }
256
+ }
257
+ ` , name , location , tier )
258
+ }
259
+
260
+ func testAccFilestoreInstance_deletionProtection_update (name , location , tier string , deletionProtection bool ) string {
261
+ deletionProtectionReason := ""
262
+ if deletionProtection {
263
+ deletionProtectionReason = "A reason for deletion protection"
264
+ }
265
+
266
+ return fmt .Sprintf (`
267
+ resource "google_filestore_instance" "instance" {
268
+ name = "%s"
269
+ zone = "%s"
270
+ tier = "%s"
271
+ description = "An instance created during testing."
272
+
273
+ file_shares {
274
+ capacity_gb = 1024
275
+ name = "share"
276
+ }
277
+
278
+ networks {
279
+ network = "default"
280
+ modes = ["MODE_IPV4"]
281
+ }
282
+
283
+ deletion_protection_enabled = %t
284
+ deletion_protection_reason = "%s"
285
+ }
286
+ ` , name , location , tier , deletionProtection , deletionProtectionReason )
287
+ }
0 commit comments