@@ -239,7 +239,7 @@ Possible values include: STANDARD, PREMIUM, BASIC_HDD, BASIC_SSD, HIGH_SCALE_SSD
239
239
Optional : true ,
240
240
ForceNew : true ,
241
241
Description : `Replication configuration, once set, this cannot be updated.
242
- Addtionally this should be specified on the replica instance only, indicating the active as the peer_instance` ,
242
+ Additionally this should be specified on the replica instance only, indicating the active as the peer_instance` ,
243
243
MaxItems : 1 ,
244
244
Elem : & schema.Resource {
245
245
Schema : map [string ]* schema.Schema {
@@ -407,6 +407,11 @@ resource, see the 'google_tags_tag_value' resource.`,
407
407
A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.
408
408
Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z"` ,
409
409
},
410
+ "peer_instance" : {
411
+ Type : schema .TypeString ,
412
+ Computed : true ,
413
+ Description : `The peer instance.` ,
414
+ },
410
415
"state" : {
411
416
Type : schema .TypeString ,
412
417
Computed : true ,
@@ -423,6 +428,11 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z"`,
423
428
},
424
429
},
425
430
},
431
+ "role" : {
432
+ Type : schema .TypeString ,
433
+ Computed : true ,
434
+ Description : `The replication role.` ,
435
+ },
426
436
},
427
437
},
428
438
},
@@ -518,6 +528,12 @@ func resourceFilestoreInstanceCreate(d *schema.ResourceData, meta interface{}) e
518
528
} else if v , ok := d .GetOkExists ("tags" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (tagsProp )) && (ok || ! reflect .DeepEqual (v , tagsProp )) {
519
529
obj ["tags" ] = tagsProp
520
530
}
531
+ replicationProp , err := expandFilestoreInstanceInitialReplication (d .Get ("initial_replication" ), d , config )
532
+ if err != nil {
533
+ return err
534
+ } else if v , ok := d .GetOkExists ("initial_replication" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (replicationProp )) && (ok || ! reflect .DeepEqual (v , replicationProp )) {
535
+ obj ["replication" ] = replicationProp
536
+ }
521
537
labelsProp , err := expandFilestoreInstanceEffectiveLabels (d .Get ("effective_labels" ), d , config )
522
538
if err != nil {
523
539
return err
@@ -1202,10 +1218,16 @@ func flattenFilestoreInstanceEffectiveReplication(v interface{}, d *schema.Resou
1202
1218
return nil
1203
1219
}
1204
1220
transformed := make (map [string ]interface {})
1221
+ transformed ["role" ] =
1222
+ flattenFilestoreInstanceEffectiveReplicationRole (original ["role" ], d , config )
1205
1223
transformed ["replicas" ] =
1206
1224
flattenFilestoreInstanceEffectiveReplicationReplicas (original ["replicas" ], d , config )
1207
1225
return []interface {}{transformed }
1208
1226
}
1227
+ func flattenFilestoreInstanceEffectiveReplicationRole (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1228
+ return v
1229
+ }
1230
+
1209
1231
func flattenFilestoreInstanceEffectiveReplicationReplicas (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1210
1232
if v == nil {
1211
1233
return v
@@ -1219,13 +1241,18 @@ func flattenFilestoreInstanceEffectiveReplicationReplicas(v interface{}, d *sche
1219
1241
continue
1220
1242
}
1221
1243
transformed = append (transformed , map [string ]interface {}{
1244
+ "peer_instance" : flattenFilestoreInstanceEffectiveReplicationReplicasPeerInstance (original ["peerInstance" ], d , config ),
1222
1245
"state" : flattenFilestoreInstanceEffectiveReplicationReplicasState (original ["state" ], d , config ),
1223
1246
"state_reasons" : flattenFilestoreInstanceEffectiveReplicationReplicasStateReasons (original ["stateReasons" ], d , config ),
1224
1247
"last_active_sync_time" : flattenFilestoreInstanceEffectiveReplicationReplicasLastActiveSyncTime (original ["lastActiveSyncTime" ], d , config ),
1225
1248
})
1226
1249
}
1227
1250
return transformed
1228
1251
}
1252
+ func flattenFilestoreInstanceEffectiveReplicationReplicasPeerInstance (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1253
+ return v
1254
+ }
1255
+
1229
1256
func flattenFilestoreInstanceEffectiveReplicationReplicasState (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1230
1257
return v
1231
1258
}
@@ -1559,6 +1586,62 @@ func expandFilestoreInstanceTags(v interface{}, d tpgresource.TerraformResourceD
1559
1586
return m , nil
1560
1587
}
1561
1588
1589
+ func expandFilestoreInstanceInitialReplication (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1590
+ l := v .([]interface {})
1591
+ if len (l ) == 0 || l [0 ] == nil {
1592
+ return nil , nil
1593
+ }
1594
+ raw := l [0 ]
1595
+ original := raw .(map [string ]interface {})
1596
+ transformed := make (map [string ]interface {})
1597
+
1598
+ transformedRole , err := expandFilestoreInstanceInitialReplicationRole (original ["role" ], d , config )
1599
+ if err != nil {
1600
+ return nil , err
1601
+ } else if val := reflect .ValueOf (transformedRole ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1602
+ transformed ["role" ] = transformedRole
1603
+ }
1604
+
1605
+ transformedReplicas , err := expandFilestoreInstanceInitialReplicationReplicas (original ["replicas" ], d , config )
1606
+ if err != nil {
1607
+ return nil , err
1608
+ } else if val := reflect .ValueOf (transformedReplicas ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1609
+ transformed ["replicas" ] = transformedReplicas
1610
+ }
1611
+
1612
+ return transformed , nil
1613
+ }
1614
+
1615
+ func expandFilestoreInstanceInitialReplicationRole (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1616
+ return v , nil
1617
+ }
1618
+
1619
+ func expandFilestoreInstanceInitialReplicationReplicas (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1620
+ l := v .([]interface {})
1621
+ req := make ([]interface {}, 0 , len (l ))
1622
+ for _ , raw := range l {
1623
+ if raw == nil {
1624
+ continue
1625
+ }
1626
+ original := raw .(map [string ]interface {})
1627
+ transformed := make (map [string ]interface {})
1628
+
1629
+ transformedPeerInstance , err := expandFilestoreInstanceInitialReplicationReplicasPeerInstance (original ["peer_instance" ], d , config )
1630
+ if err != nil {
1631
+ return nil , err
1632
+ } else if val := reflect .ValueOf (transformedPeerInstance ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1633
+ transformed ["peerInstance" ] = transformedPeerInstance
1634
+ }
1635
+
1636
+ req = append (req , transformed )
1637
+ }
1638
+ return req , nil
1639
+ }
1640
+
1641
+ func expandFilestoreInstanceInitialReplicationReplicasPeerInstance (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1642
+ return v , nil
1643
+ }
1644
+
1562
1645
func expandFilestoreInstanceEffectiveLabels (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (map [string ]string , error ) {
1563
1646
if v == nil {
1564
1647
return map [string ]string {}, nil
0 commit comments