@@ -240,6 +240,23 @@ These should be specified as project numbers only.`,
240
240
ValidateFunc : verify .ValidateRegexp (`^\d+$` ),
241
241
},
242
242
},
243
+ "psc_interface_configs" : {
244
+ Type : schema .TypeList ,
245
+ Optional : true ,
246
+ Description : `Configurations for setting up PSC interfaces attached to the instance
247
+ which are used for outbound connectivity. Currently, AlloyDB supports only 0 or 1 PSC interface.` ,
248
+ Elem : & schema.Resource {
249
+ Schema : map [string ]* schema.Schema {
250
+ "network_attachment_resource" : {
251
+ Type : schema .TypeString ,
252
+ Optional : true ,
253
+ Description : `The network attachment resource created in the consumer project to which the PSC interface will be linked.
254
+ This is of the format: "projects/${CONSUMER_PROJECT}/regions/${REGION}/networkAttachments/${NETWORK_ATTACHMENT_NAME}".
255
+ The network attachment must be in the same region as the instance.` ,
256
+ },
257
+ },
258
+ },
259
+ },
243
260
"psc_dns_name" : {
244
261
Type : schema .TypeString ,
245
262
Computed : true ,
@@ -1147,6 +1164,8 @@ func flattenAlloydbInstancePscInstanceConfig(v interface{}, d *schema.ResourceDa
1147
1164
flattenAlloydbInstancePscInstanceConfigAllowedConsumerProjects (original ["allowedConsumerProjects" ], d , config )
1148
1165
transformed ["psc_dns_name" ] =
1149
1166
flattenAlloydbInstancePscInstanceConfigPscDnsName (original ["pscDnsName" ], d , config )
1167
+ transformed ["psc_interface_configs" ] =
1168
+ flattenAlloydbInstancePscInstanceConfigPscInterfaceConfigs (original ["pscInterfaceConfigs" ], d , config )
1150
1169
return []interface {}{transformed }
1151
1170
}
1152
1171
func flattenAlloydbInstancePscInstanceConfigServiceAttachmentLink (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
@@ -1161,6 +1180,28 @@ func flattenAlloydbInstancePscInstanceConfigPscDnsName(v interface{}, d *schema.
1161
1180
return v
1162
1181
}
1163
1182
1183
+ func flattenAlloydbInstancePscInstanceConfigPscInterfaceConfigs (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1184
+ if v == nil {
1185
+ return v
1186
+ }
1187
+ l := v .([]interface {})
1188
+ transformed := make ([]interface {}, 0 , len (l ))
1189
+ for _ , raw := range l {
1190
+ original := raw .(map [string ]interface {})
1191
+ if len (original ) < 1 {
1192
+ // Do not include empty json objects coming back from the api
1193
+ continue
1194
+ }
1195
+ transformed = append (transformed , map [string ]interface {}{
1196
+ "network_attachment_resource" : flattenAlloydbInstancePscInstanceConfigPscInterfaceConfigsNetworkAttachmentResource (original ["networkAttachmentResource" ], d , config ),
1197
+ })
1198
+ }
1199
+ return transformed
1200
+ }
1201
+ func flattenAlloydbInstancePscInstanceConfigPscInterfaceConfigsNetworkAttachmentResource (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1202
+ return v
1203
+ }
1204
+
1164
1205
func flattenAlloydbInstanceNetworkConfig (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1165
1206
if v == nil {
1166
1207
return nil
@@ -1451,6 +1492,13 @@ func expandAlloydbInstancePscInstanceConfig(v interface{}, d tpgresource.Terrafo
1451
1492
transformed ["pscDnsName" ] = transformedPscDnsName
1452
1493
}
1453
1494
1495
+ transformedPscInterfaceConfigs , err := expandAlloydbInstancePscInstanceConfigPscInterfaceConfigs (original ["psc_interface_configs" ], d , config )
1496
+ if err != nil {
1497
+ return nil , err
1498
+ } else if val := reflect .ValueOf (transformedPscInterfaceConfigs ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1499
+ transformed ["pscInterfaceConfigs" ] = transformedPscInterfaceConfigs
1500
+ }
1501
+
1454
1502
return transformed , nil
1455
1503
}
1456
1504
@@ -1466,6 +1514,32 @@ func expandAlloydbInstancePscInstanceConfigPscDnsName(v interface{}, d tpgresour
1466
1514
return v , nil
1467
1515
}
1468
1516
1517
+ func expandAlloydbInstancePscInstanceConfigPscInterfaceConfigs (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1518
+ l := v .([]interface {})
1519
+ req := make ([]interface {}, 0 , len (l ))
1520
+ for _ , raw := range l {
1521
+ if raw == nil {
1522
+ continue
1523
+ }
1524
+ original := raw .(map [string ]interface {})
1525
+ transformed := make (map [string ]interface {})
1526
+
1527
+ transformedNetworkAttachmentResource , err := expandAlloydbInstancePscInstanceConfigPscInterfaceConfigsNetworkAttachmentResource (original ["network_attachment_resource" ], d , config )
1528
+ if err != nil {
1529
+ return nil , err
1530
+ } else if val := reflect .ValueOf (transformedNetworkAttachmentResource ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1531
+ transformed ["networkAttachmentResource" ] = transformedNetworkAttachmentResource
1532
+ }
1533
+
1534
+ req = append (req , transformed )
1535
+ }
1536
+ return req , nil
1537
+ }
1538
+
1539
+ func expandAlloydbInstancePscInstanceConfigPscInterfaceConfigsNetworkAttachmentResource (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1540
+ return v , nil
1541
+ }
1542
+
1469
1543
func expandAlloydbInstanceNetworkConfig (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1470
1544
l := v .([]interface {})
1471
1545
if len (l ) == 0 || l [0 ] == nil {
0 commit comments