@@ -215,6 +215,39 @@ the same instance.`,
215
215
},
216
216
},
217
217
},
218
+ "psc_instance_config" : {
219
+ Type : schema .TypeList ,
220
+ Optional : true ,
221
+ Description : `Configuration for Private Service Connect (PSC) for the instance.` ,
222
+ MaxItems : 1 ,
223
+ Elem : & schema.Resource {
224
+ Schema : map [string ]* schema.Schema {
225
+ "allowed_consumer_projects" : {
226
+ Type : schema .TypeList ,
227
+ Optional : true ,
228
+ Description : `List of consumer projects that are allowed to create PSC endpoints to service-attachments to this instance.
229
+ These should be specified as project numbers only.` ,
230
+ Elem : & schema.Schema {
231
+ Type : schema .TypeString ,
232
+ ValidateFunc : verify .ValidateRegexp (`^\d+$` ),
233
+ },
234
+ },
235
+ "psc_dns_name" : {
236
+ Type : schema .TypeString ,
237
+ Computed : true ,
238
+ Description : `The DNS name of the instance for PSC connectivity.
239
+ Name convention: <uid>.<uid>.<region>.alloydb-psc.goog` ,
240
+ },
241
+ "service_attachment_link" : {
242
+ Type : schema .TypeString ,
243
+ Computed : true ,
244
+ Description : `The service attachment created when Private Service Connect (PSC) is enabled for the instance.
245
+ The name of the resource will be in the format of
246
+ 'projects/<alloydb-tenant-project-number>/regions/<region-name>/serviceAttachments/<service-attachment-name>'` ,
247
+ },
248
+ },
249
+ },
250
+ },
218
251
"query_insights_config" : {
219
252
Type : schema .TypeList ,
220
253
Computed : true ,
@@ -390,6 +423,12 @@ func resourceAlloydbInstanceCreate(d *schema.ResourceData, meta interface{}) err
390
423
} else if v , ok := d .GetOkExists ("client_connection_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (clientConnectionConfigProp )) && (ok || ! reflect .DeepEqual (v , clientConnectionConfigProp )) {
391
424
obj ["clientConnectionConfig" ] = clientConnectionConfigProp
392
425
}
426
+ pscInstanceConfigProp , err := expandAlloydbInstancePscInstanceConfig (d .Get ("psc_instance_config" ), d , config )
427
+ if err != nil {
428
+ return err
429
+ } else if v , ok := d .GetOkExists ("psc_instance_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (pscInstanceConfigProp )) && (ok || ! reflect .DeepEqual (v , pscInstanceConfigProp )) {
430
+ obj ["pscInstanceConfig" ] = pscInstanceConfigProp
431
+ }
393
432
networkConfigProp , err := expandAlloydbInstanceNetworkConfig (d .Get ("network_config" ), d , config )
394
433
if err != nil {
395
434
return err
@@ -606,6 +645,9 @@ func resourceAlloydbInstanceRead(d *schema.ResourceData, meta interface{}) error
606
645
if err := d .Set ("client_connection_config" , flattenAlloydbInstanceClientConnectionConfig (res ["clientConnectionConfig" ], d , config )); err != nil {
607
646
return fmt .Errorf ("Error reading Instance: %s" , err )
608
647
}
648
+ if err := d .Set ("psc_instance_config" , flattenAlloydbInstancePscInstanceConfig (res ["pscInstanceConfig" ], d , config )); err != nil {
649
+ return fmt .Errorf ("Error reading Instance: %s" , err )
650
+ }
609
651
if err := d .Set ("network_config" , flattenAlloydbInstanceNetworkConfig (res ["networkConfig" ], d , config )); err != nil {
610
652
return fmt .Errorf ("Error reading Instance: %s" , err )
611
653
}
@@ -684,6 +726,12 @@ func resourceAlloydbInstanceUpdate(d *schema.ResourceData, meta interface{}) err
684
726
} else if v , ok := d .GetOkExists ("client_connection_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , clientConnectionConfigProp )) {
685
727
obj ["clientConnectionConfig" ] = clientConnectionConfigProp
686
728
}
729
+ pscInstanceConfigProp , err := expandAlloydbInstancePscInstanceConfig (d .Get ("psc_instance_config" ), d , config )
730
+ if err != nil {
731
+ return err
732
+ } else if v , ok := d .GetOkExists ("psc_instance_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , pscInstanceConfigProp )) {
733
+ obj ["pscInstanceConfig" ] = pscInstanceConfigProp
734
+ }
687
735
networkConfigProp , err := expandAlloydbInstanceNetworkConfig (d .Get ("network_config" ), d , config )
688
736
if err != nil {
689
737
return err
@@ -744,6 +792,10 @@ func resourceAlloydbInstanceUpdate(d *schema.ResourceData, meta interface{}) err
744
792
updateMask = append (updateMask , "clientConnectionConfig" )
745
793
}
746
794
795
+ if d .HasChange ("psc_instance_config" ) {
796
+ updateMask = append (updateMask , "pscInstanceConfig" )
797
+ }
798
+
747
799
if d .HasChange ("network_config" ) {
748
800
updateMask = append (updateMask , "networkConfig" )
749
801
}
@@ -1118,6 +1170,35 @@ func flattenAlloydbInstanceClientConnectionConfigSslConfigSslMode(v interface{},
1118
1170
return v
1119
1171
}
1120
1172
1173
+ func flattenAlloydbInstancePscInstanceConfig (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1174
+ if v == nil {
1175
+ return nil
1176
+ }
1177
+ original := v .(map [string ]interface {})
1178
+ if len (original ) == 0 {
1179
+ return nil
1180
+ }
1181
+ transformed := make (map [string ]interface {})
1182
+ transformed ["service_attachment_link" ] =
1183
+ flattenAlloydbInstancePscInstanceConfigServiceAttachmentLink (original ["serviceAttachmentLink" ], d , config )
1184
+ transformed ["allowed_consumer_projects" ] =
1185
+ flattenAlloydbInstancePscInstanceConfigAllowedConsumerProjects (original ["allowedConsumerProjects" ], d , config )
1186
+ transformed ["psc_dns_name" ] =
1187
+ flattenAlloydbInstancePscInstanceConfigPscDnsName (original ["pscDnsName" ], d , config )
1188
+ return []interface {}{transformed }
1189
+ }
1190
+ func flattenAlloydbInstancePscInstanceConfigServiceAttachmentLink (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1191
+ return v
1192
+ }
1193
+
1194
+ func flattenAlloydbInstancePscInstanceConfigAllowedConsumerProjects (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1195
+ return v
1196
+ }
1197
+
1198
+ func flattenAlloydbInstancePscInstanceConfigPscDnsName (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1199
+ return v
1200
+ }
1201
+
1121
1202
func flattenAlloydbInstanceNetworkConfig (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1122
1203
if v == nil {
1123
1204
return nil
@@ -1368,6 +1449,51 @@ func expandAlloydbInstanceClientConnectionConfigSslConfigSslMode(v interface{},
1368
1449
return v , nil
1369
1450
}
1370
1451
1452
+ func expandAlloydbInstancePscInstanceConfig (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1453
+ l := v .([]interface {})
1454
+ if len (l ) == 0 || l [0 ] == nil {
1455
+ return nil , nil
1456
+ }
1457
+ raw := l [0 ]
1458
+ original := raw .(map [string ]interface {})
1459
+ transformed := make (map [string ]interface {})
1460
+
1461
+ transformedServiceAttachmentLink , err := expandAlloydbInstancePscInstanceConfigServiceAttachmentLink (original ["service_attachment_link" ], d , config )
1462
+ if err != nil {
1463
+ return nil , err
1464
+ } else if val := reflect .ValueOf (transformedServiceAttachmentLink ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1465
+ transformed ["serviceAttachmentLink" ] = transformedServiceAttachmentLink
1466
+ }
1467
+
1468
+ transformedAllowedConsumerProjects , err := expandAlloydbInstancePscInstanceConfigAllowedConsumerProjects (original ["allowed_consumer_projects" ], d , config )
1469
+ if err != nil {
1470
+ return nil , err
1471
+ } else if val := reflect .ValueOf (transformedAllowedConsumerProjects ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1472
+ transformed ["allowedConsumerProjects" ] = transformedAllowedConsumerProjects
1473
+ }
1474
+
1475
+ transformedPscDnsName , err := expandAlloydbInstancePscInstanceConfigPscDnsName (original ["psc_dns_name" ], d , config )
1476
+ if err != nil {
1477
+ return nil , err
1478
+ } else if val := reflect .ValueOf (transformedPscDnsName ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1479
+ transformed ["pscDnsName" ] = transformedPscDnsName
1480
+ }
1481
+
1482
+ return transformed , nil
1483
+ }
1484
+
1485
+ func expandAlloydbInstancePscInstanceConfigServiceAttachmentLink (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1486
+ return v , nil
1487
+ }
1488
+
1489
+ func expandAlloydbInstancePscInstanceConfigAllowedConsumerProjects (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1490
+ return v , nil
1491
+ }
1492
+
1493
+ func expandAlloydbInstancePscInstanceConfigPscDnsName (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1494
+ return v , nil
1495
+ }
1496
+
1371
1497
func expandAlloydbInstanceNetworkConfig (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1372
1498
l := v .([]interface {})
1373
1499
if len (l ) == 0 || l [0 ] == nil {
0 commit comments