@@ -256,6 +256,57 @@ Please refer to the field 'effective_labels' for all of the labels present on th
256
256
Description : `The name of the location of the instance. This can be a region for ENTERPRISE tier instances.` ,
257
257
ExactlyOneOf : []string {},
258
258
},
259
+ "performance_config" : {
260
+ Type : schema .TypeList ,
261
+ Optional : true ,
262
+ Description : `Performance configuration for the instance. If not provided,
263
+ the default performance settings will be used.` ,
264
+ MaxItems : 1 ,
265
+ Elem : & schema.Resource {
266
+ Schema : map [string ]* schema.Schema {
267
+ "fixed_iops" : {
268
+ Type : schema .TypeList ,
269
+ Optional : true ,
270
+ Description : `The instance will have a fixed provisioned IOPS value,
271
+ which will remain constant regardless of instance
272
+ capacity.` ,
273
+ MaxItems : 1 ,
274
+ Elem : & schema.Resource {
275
+ Schema : map [string ]* schema.Schema {
276
+ "max_iops" : {
277
+ Type : schema .TypeInt ,
278
+ Optional : true ,
279
+ Description : `The number of IOPS to provision for the instance.
280
+ max_iops must be in multiple of 1000.` ,
281
+ },
282
+ },
283
+ },
284
+ ConflictsWith : []string {},
285
+ },
286
+ "iops_per_tb" : {
287
+ Type : schema .TypeList ,
288
+ Optional : true ,
289
+ Description : `The instance provisioned IOPS will change dynamically
290
+ based on the capacity of the instance.` ,
291
+ MaxItems : 1 ,
292
+ Elem : & schema.Resource {
293
+ Schema : map [string ]* schema.Schema {
294
+ "max_iops_per_tb" : {
295
+ Type : schema .TypeInt ,
296
+ Optional : true ,
297
+ Description : `The instance max IOPS will be calculated by multiplying
298
+ the capacity of the instance (TB) by max_iops_per_tb,
299
+ and rounding to the nearest 1000. The instance max IOPS
300
+ will be changed dynamically based on the instance
301
+ capacity.` ,
302
+ },
303
+ },
304
+ },
305
+ ConflictsWith : []string {},
306
+ },
307
+ },
308
+ },
309
+ },
259
310
"protocol" : {
260
311
Type : schema .TypeString ,
261
312
Optional : true ,
@@ -367,6 +418,12 @@ func resourceFilestoreInstanceCreate(d *schema.ResourceData, meta interface{}) e
367
418
} else if v , ok := d .GetOkExists ("deletion_protection_reason" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (deletionProtectionReasonProp )) && (ok || ! reflect .DeepEqual (v , deletionProtectionReasonProp )) {
368
419
obj ["deletionProtectionReason" ] = deletionProtectionReasonProp
369
420
}
421
+ performanceConfigProp , err := expandFilestoreInstancePerformanceConfig (d .Get ("performance_config" ), d , config )
422
+ if err != nil {
423
+ return err
424
+ } else if v , ok := d .GetOkExists ("performance_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (performanceConfigProp )) && (ok || ! reflect .DeepEqual (v , performanceConfigProp )) {
425
+ obj ["performanceConfig" ] = performanceConfigProp
426
+ }
370
427
labelsProp , err := expandFilestoreInstanceEffectiveLabels (d .Get ("effective_labels" ), d , config )
371
428
if err != nil {
372
429
return err
@@ -534,6 +591,9 @@ func resourceFilestoreInstanceRead(d *schema.ResourceData, meta interface{}) err
534
591
if err := d .Set ("deletion_protection_reason" , flattenFilestoreInstanceDeletionProtectionReason (res ["deletionProtectionReason" ], d , config )); err != nil {
535
592
return fmt .Errorf ("Error reading Instance: %s" , err )
536
593
}
594
+ if err := d .Set ("performance_config" , flattenFilestoreInstancePerformanceConfig (res ["performanceConfig" ], d , config )); err != nil {
595
+ return fmt .Errorf ("Error reading Instance: %s" , err )
596
+ }
537
597
if err := d .Set ("terraform_labels" , flattenFilestoreInstanceTerraformLabels (res ["labels" ], d , config )); err != nil {
538
598
return fmt .Errorf ("Error reading Instance: %s" , err )
539
599
}
@@ -584,6 +644,12 @@ func resourceFilestoreInstanceUpdate(d *schema.ResourceData, meta interface{}) e
584
644
} else if v , ok := d .GetOkExists ("deletion_protection_reason" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , deletionProtectionReasonProp )) {
585
645
obj ["deletionProtectionReason" ] = deletionProtectionReasonProp
586
646
}
647
+ performanceConfigProp , err := expandFilestoreInstancePerformanceConfig (d .Get ("performance_config" ), d , config )
648
+ if err != nil {
649
+ return err
650
+ } else if v , ok := d .GetOkExists ("performance_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , performanceConfigProp )) {
651
+ obj ["performanceConfig" ] = performanceConfigProp
652
+ }
587
653
labelsProp , err := expandFilestoreInstanceEffectiveLabels (d .Get ("effective_labels" ), d , config )
588
654
if err != nil {
589
655
return err
@@ -616,6 +682,10 @@ func resourceFilestoreInstanceUpdate(d *schema.ResourceData, meta interface{}) e
616
682
updateMask = append (updateMask , "deletionProtectionReason" )
617
683
}
618
684
685
+ if d .HasChange ("performance_config" ) {
686
+ updateMask = append (updateMask , "performanceConfig" )
687
+ }
688
+
619
689
if d .HasChange ("effective_labels" ) {
620
690
updateMask = append (updateMask , "labels" )
621
691
}
@@ -951,6 +1021,81 @@ func flattenFilestoreInstanceDeletionProtectionReason(v interface{}, d *schema.R
951
1021
return v
952
1022
}
953
1023
1024
+ func flattenFilestoreInstancePerformanceConfig (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1025
+ if v == nil {
1026
+ return nil
1027
+ }
1028
+ original := v .(map [string ]interface {})
1029
+ if len (original ) == 0 {
1030
+ return nil
1031
+ }
1032
+ transformed := make (map [string ]interface {})
1033
+ transformed ["iops_per_tb" ] =
1034
+ flattenFilestoreInstancePerformanceConfigIopsPerTb (original ["iopsPerTb" ], d , config )
1035
+ transformed ["fixed_iops" ] =
1036
+ flattenFilestoreInstancePerformanceConfigFixedIops (original ["fixedIops" ], d , config )
1037
+ return []interface {}{transformed }
1038
+ }
1039
+ func flattenFilestoreInstancePerformanceConfigIopsPerTb (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1040
+ if v == nil {
1041
+ return nil
1042
+ }
1043
+ original := v .(map [string ]interface {})
1044
+ if len (original ) == 0 {
1045
+ return nil
1046
+ }
1047
+ transformed := make (map [string ]interface {})
1048
+ transformed ["max_iops_per_tb" ] =
1049
+ flattenFilestoreInstancePerformanceConfigIopsPerTbMaxIopsPerTb (original ["maxIopsPerTb" ], d , config )
1050
+ return []interface {}{transformed }
1051
+ }
1052
+ func flattenFilestoreInstancePerformanceConfigIopsPerTbMaxIopsPerTb (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1053
+ // Handles the string fixed64 format
1054
+ if strVal , ok := v .(string ); ok {
1055
+ if intVal , err := tpgresource .StringToFixed64 (strVal ); err == nil {
1056
+ return intVal
1057
+ }
1058
+ }
1059
+
1060
+ // number values are represented as float64
1061
+ if floatVal , ok := v .(float64 ); ok {
1062
+ intVal := int (floatVal )
1063
+ return intVal
1064
+ }
1065
+
1066
+ return v // let terraform core handle it otherwise
1067
+ }
1068
+
1069
+ func flattenFilestoreInstancePerformanceConfigFixedIops (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1070
+ if v == nil {
1071
+ return nil
1072
+ }
1073
+ original := v .(map [string ]interface {})
1074
+ if len (original ) == 0 {
1075
+ return nil
1076
+ }
1077
+ transformed := make (map [string ]interface {})
1078
+ transformed ["max_iops" ] =
1079
+ flattenFilestoreInstancePerformanceConfigFixedIopsMaxIops (original ["maxIops" ], d , config )
1080
+ return []interface {}{transformed }
1081
+ }
1082
+ func flattenFilestoreInstancePerformanceConfigFixedIopsMaxIops (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1083
+ // Handles the string fixed64 format
1084
+ if strVal , ok := v .(string ); ok {
1085
+ if intVal , err := tpgresource .StringToFixed64 (strVal ); err == nil {
1086
+ return intVal
1087
+ }
1088
+ }
1089
+
1090
+ // number values are represented as float64
1091
+ if floatVal , ok := v .(float64 ); ok {
1092
+ intVal := int (floatVal )
1093
+ return intVal
1094
+ }
1095
+
1096
+ return v // let terraform core handle it otherwise
1097
+ }
1098
+
954
1099
func flattenFilestoreInstanceTerraformLabels (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
955
1100
if v == nil {
956
1101
return v
@@ -1189,6 +1334,78 @@ func expandFilestoreInstanceDeletionProtectionReason(v interface{}, d tpgresourc
1189
1334
return v , nil
1190
1335
}
1191
1336
1337
+ func expandFilestoreInstancePerformanceConfig (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1338
+ l := v .([]interface {})
1339
+ if len (l ) == 0 || l [0 ] == nil {
1340
+ return nil , nil
1341
+ }
1342
+ raw := l [0 ]
1343
+ original := raw .(map [string ]interface {})
1344
+ transformed := make (map [string ]interface {})
1345
+
1346
+ transformedIopsPerTb , err := expandFilestoreInstancePerformanceConfigIopsPerTb (original ["iops_per_tb" ], d , config )
1347
+ if err != nil {
1348
+ return nil , err
1349
+ } else if val := reflect .ValueOf (transformedIopsPerTb ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1350
+ transformed ["iopsPerTb" ] = transformedIopsPerTb
1351
+ }
1352
+
1353
+ transformedFixedIops , err := expandFilestoreInstancePerformanceConfigFixedIops (original ["fixed_iops" ], d , config )
1354
+ if err != nil {
1355
+ return nil , err
1356
+ } else if val := reflect .ValueOf (transformedFixedIops ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1357
+ transformed ["fixedIops" ] = transformedFixedIops
1358
+ }
1359
+
1360
+ return transformed , nil
1361
+ }
1362
+
1363
+ func expandFilestoreInstancePerformanceConfigIopsPerTb (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1364
+ l := v .([]interface {})
1365
+ if len (l ) == 0 || l [0 ] == nil {
1366
+ return nil , nil
1367
+ }
1368
+ raw := l [0 ]
1369
+ original := raw .(map [string ]interface {})
1370
+ transformed := make (map [string ]interface {})
1371
+
1372
+ transformedMaxIopsPerTb , err := expandFilestoreInstancePerformanceConfigIopsPerTbMaxIopsPerTb (original ["max_iops_per_tb" ], d , config )
1373
+ if err != nil {
1374
+ return nil , err
1375
+ } else if val := reflect .ValueOf (transformedMaxIopsPerTb ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1376
+ transformed ["maxIopsPerTb" ] = transformedMaxIopsPerTb
1377
+ }
1378
+
1379
+ return transformed , nil
1380
+ }
1381
+
1382
+ func expandFilestoreInstancePerformanceConfigIopsPerTbMaxIopsPerTb (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1383
+ return v , nil
1384
+ }
1385
+
1386
+ func expandFilestoreInstancePerformanceConfigFixedIops (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1387
+ l := v .([]interface {})
1388
+ if len (l ) == 0 || l [0 ] == nil {
1389
+ return nil , nil
1390
+ }
1391
+ raw := l [0 ]
1392
+ original := raw .(map [string ]interface {})
1393
+ transformed := make (map [string ]interface {})
1394
+
1395
+ transformedMaxIops , err := expandFilestoreInstancePerformanceConfigFixedIopsMaxIops (original ["max_iops" ], d , config )
1396
+ if err != nil {
1397
+ return nil , err
1398
+ } else if val := reflect .ValueOf (transformedMaxIops ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1399
+ transformed ["maxIops" ] = transformedMaxIops
1400
+ }
1401
+
1402
+ return transformed , nil
1403
+ }
1404
+
1405
+ func expandFilestoreInstancePerformanceConfigFixedIopsMaxIops (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1406
+ return v , nil
1407
+ }
1408
+
1192
1409
func expandFilestoreInstanceEffectiveLabels (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (map [string ]string , error ) {
1193
1410
if v == nil {
1194
1411
return map [string ]string {}, nil
0 commit comments