@@ -217,6 +217,16 @@ addresses reserved for this instance.`,
217
217
Description : `The service tier of the instance.
218
218
Possible values include: STANDARD, PREMIUM, BASIC_HDD, BASIC_SSD, HIGH_SCALE_SSD, ZONAL, REGIONAL and ENTERPRISE` ,
219
219
},
220
+ "deletion_protection_enabled" : {
221
+ Type : schema .TypeBool ,
222
+ Optional : true ,
223
+ Description : `Indicates whether the instance is protected against deletion.` ,
224
+ },
225
+ "deletion_protection_reason" : {
226
+ Type : schema .TypeString ,
227
+ Optional : true ,
228
+ Description : `The reason for enabling deletion protection.` ,
229
+ },
220
230
"description" : {
221
231
Type : schema .TypeString ,
222
232
Optional : true ,
@@ -345,6 +355,18 @@ func resourceFilestoreInstanceCreate(d *schema.ResourceData, meta interface{}) e
345
355
} else if v , ok := d .GetOkExists ("kms_key_name" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (kmsKeyNameProp )) && (ok || ! reflect .DeepEqual (v , kmsKeyNameProp )) {
346
356
obj ["kmsKeyName" ] = kmsKeyNameProp
347
357
}
358
+ deletionProtectionEnabledProp , err := expandFilestoreInstanceDeletionProtectionEnabled (d .Get ("deletion_protection_enabled" ), d , config )
359
+ if err != nil {
360
+ return err
361
+ } else if v , ok := d .GetOkExists ("deletion_protection_enabled" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (deletionProtectionEnabledProp )) && (ok || ! reflect .DeepEqual (v , deletionProtectionEnabledProp )) {
362
+ obj ["deletionProtectionEnabled" ] = deletionProtectionEnabledProp
363
+ }
364
+ deletionProtectionReasonProp , err := expandFilestoreInstanceDeletionProtectionReason (d .Get ("deletion_protection_reason" ), d , config )
365
+ if err != nil {
366
+ return err
367
+ } else if v , ok := d .GetOkExists ("deletion_protection_reason" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (deletionProtectionReasonProp )) && (ok || ! reflect .DeepEqual (v , deletionProtectionReasonProp )) {
368
+ obj ["deletionProtectionReason" ] = deletionProtectionReasonProp
369
+ }
348
370
labelsProp , err := expandFilestoreInstanceEffectiveLabels (d .Get ("effective_labels" ), d , config )
349
371
if err != nil {
350
372
return err
@@ -506,6 +528,12 @@ func resourceFilestoreInstanceRead(d *schema.ResourceData, meta interface{}) err
506
528
if err := d .Set ("kms_key_name" , flattenFilestoreInstanceKmsKeyName (res ["kmsKeyName" ], d , config )); err != nil {
507
529
return fmt .Errorf ("Error reading Instance: %s" , err )
508
530
}
531
+ if err := d .Set ("deletion_protection_enabled" , flattenFilestoreInstanceDeletionProtectionEnabled (res ["deletionProtectionEnabled" ], d , config )); err != nil {
532
+ return fmt .Errorf ("Error reading Instance: %s" , err )
533
+ }
534
+ if err := d .Set ("deletion_protection_reason" , flattenFilestoreInstanceDeletionProtectionReason (res ["deletionProtectionReason" ], d , config )); err != nil {
535
+ return fmt .Errorf ("Error reading Instance: %s" , err )
536
+ }
509
537
if err := d .Set ("terraform_labels" , flattenFilestoreInstanceTerraformLabels (res ["labels" ], d , config )); err != nil {
510
538
return fmt .Errorf ("Error reading Instance: %s" , err )
511
539
}
@@ -544,6 +572,18 @@ func resourceFilestoreInstanceUpdate(d *schema.ResourceData, meta interface{}) e
544
572
} else if v , ok := d .GetOkExists ("file_shares" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , fileSharesProp )) {
545
573
obj ["fileShares" ] = fileSharesProp
546
574
}
575
+ deletionProtectionEnabledProp , err := expandFilestoreInstanceDeletionProtectionEnabled (d .Get ("deletion_protection_enabled" ), d , config )
576
+ if err != nil {
577
+ return err
578
+ } else if v , ok := d .GetOkExists ("deletion_protection_enabled" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , deletionProtectionEnabledProp )) {
579
+ obj ["deletionProtectionEnabled" ] = deletionProtectionEnabledProp
580
+ }
581
+ deletionProtectionReasonProp , err := expandFilestoreInstanceDeletionProtectionReason (d .Get ("deletion_protection_reason" ), d , config )
582
+ if err != nil {
583
+ return err
584
+ } else if v , ok := d .GetOkExists ("deletion_protection_reason" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , deletionProtectionReasonProp )) {
585
+ obj ["deletionProtectionReason" ] = deletionProtectionReasonProp
586
+ }
547
587
labelsProp , err := expandFilestoreInstanceEffectiveLabels (d .Get ("effective_labels" ), d , config )
548
588
if err != nil {
549
589
return err
@@ -568,6 +608,14 @@ func resourceFilestoreInstanceUpdate(d *schema.ResourceData, meta interface{}) e
568
608
updateMask = append (updateMask , "fileShares" )
569
609
}
570
610
611
+ if d .HasChange ("deletion_protection_enabled" ) {
612
+ updateMask = append (updateMask , "deletionProtectionEnabled" )
613
+ }
614
+
615
+ if d .HasChange ("deletion_protection_reason" ) {
616
+ updateMask = append (updateMask , "deletionProtectionReason" )
617
+ }
618
+
571
619
if d .HasChange ("effective_labels" ) {
572
620
updateMask = append (updateMask , "labels" )
573
621
}
@@ -895,6 +943,14 @@ func flattenFilestoreInstanceKmsKeyName(v interface{}, d *schema.ResourceData, c
895
943
return v
896
944
}
897
945
946
+ func flattenFilestoreInstanceDeletionProtectionEnabled (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
947
+ return v
948
+ }
949
+
950
+ func flattenFilestoreInstanceDeletionProtectionReason (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
951
+ return v
952
+ }
953
+
898
954
func flattenFilestoreInstanceTerraformLabels (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
899
955
if v == nil {
900
956
return v
@@ -1125,6 +1181,14 @@ func expandFilestoreInstanceKmsKeyName(v interface{}, d tpgresource.TerraformRes
1125
1181
return v , nil
1126
1182
}
1127
1183
1184
+ func expandFilestoreInstanceDeletionProtectionEnabled (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1185
+ return v , nil
1186
+ }
1187
+
1188
+ func expandFilestoreInstanceDeletionProtectionReason (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1189
+ return v , nil
1190
+ }
1191
+
1128
1192
func expandFilestoreInstanceEffectiveLabels (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (map [string ]string , error ) {
1129
1193
if v == nil {
1130
1194
return map [string ]string {}, nil
0 commit comments