@@ -215,6 +215,39 @@ the same instance.`,
215215 },
216216 },
217217 },
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+ },
218251 "query_insights_config" : {
219252 Type : schema .TypeList ,
220253 Computed : true ,
@@ -390,6 +423,12 @@ func resourceAlloydbInstanceCreate(d *schema.ResourceData, meta interface{}) err
390423 } else if v , ok := d .GetOkExists ("client_connection_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (clientConnectionConfigProp )) && (ok || ! reflect .DeepEqual (v , clientConnectionConfigProp )) {
391424 obj ["clientConnectionConfig" ] = clientConnectionConfigProp
392425 }
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+ }
393432 networkConfigProp , err := expandAlloydbInstanceNetworkConfig (d .Get ("network_config" ), d , config )
394433 if err != nil {
395434 return err
@@ -606,6 +645,9 @@ func resourceAlloydbInstanceRead(d *schema.ResourceData, meta interface{}) error
606645 if err := d .Set ("client_connection_config" , flattenAlloydbInstanceClientConnectionConfig (res ["clientConnectionConfig" ], d , config )); err != nil {
607646 return fmt .Errorf ("Error reading Instance: %s" , err )
608647 }
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+ }
609651 if err := d .Set ("network_config" , flattenAlloydbInstanceNetworkConfig (res ["networkConfig" ], d , config )); err != nil {
610652 return fmt .Errorf ("Error reading Instance: %s" , err )
611653 }
@@ -684,6 +726,12 @@ func resourceAlloydbInstanceUpdate(d *schema.ResourceData, meta interface{}) err
684726 } else if v , ok := d .GetOkExists ("client_connection_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , clientConnectionConfigProp )) {
685727 obj ["clientConnectionConfig" ] = clientConnectionConfigProp
686728 }
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+ }
687735 networkConfigProp , err := expandAlloydbInstanceNetworkConfig (d .Get ("network_config" ), d , config )
688736 if err != nil {
689737 return err
@@ -744,6 +792,10 @@ func resourceAlloydbInstanceUpdate(d *schema.ResourceData, meta interface{}) err
744792 updateMask = append (updateMask , "clientConnectionConfig" )
745793 }
746794
795+ if d .HasChange ("psc_instance_config" ) {
796+ updateMask = append (updateMask , "pscInstanceConfig" )
797+ }
798+
747799 if d .HasChange ("network_config" ) {
748800 updateMask = append (updateMask , "networkConfig" )
749801 }
@@ -1118,6 +1170,35 @@ func flattenAlloydbInstanceClientConnectionConfigSslConfigSslMode(v interface{},
11181170 return v
11191171}
11201172
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+
11211202func flattenAlloydbInstanceNetworkConfig (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
11221203 if v == nil {
11231204 return nil
@@ -1368,6 +1449,51 @@ func expandAlloydbInstanceClientConnectionConfigSslConfigSslMode(v interface{},
13681449 return v , nil
13691450}
13701451
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+
13711497func expandAlloydbInstanceNetworkConfig (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
13721498 l := v .([]interface {})
13731499 if len (l ) == 0 || l [0 ] == nil {
0 commit comments