Skip to content

Commit 4fde73f

Browse files
authored
fix: add psc service attachment link in the data (#15930)
Signed-off-by: Julia Zou <[email protected]>
1 parent c6a5da7 commit 4fde73f

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

mmv1/third_party/terraform/services/sql/data_source_sql_database_instances.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ func flattenDatasourceGoogleDatabaseInstancesList(fetchedInstances []*sqladmin.D
179179
instance["master_instance_name"] = strings.TrimPrefix(rawInstance.MasterInstanceName, project+":")
180180
instance["project"] = project
181181
instance["self_link"] = rawInstance.SelfLink
182+
instance["psc_service_attachment_link"] = rawInstance.PscServiceAttachmentLink
182183

183184
instances = append(instances, instance)
184185
}

mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,6 @@ func resourceSqlDatabaseInstanceCreate(d *schema.ResourceData, meta interface{})
15301530
if _, ok := d.GetOk("node_count"); ok {
15311531
instance.NodeCount = int64(d.Get("node_count").(int))
15321532
}
1533-
15341533
if _, ok := d.GetOk("root_password_wo_version"); ok {
15351534
instance.RootPassword = tpgresource.GetRawConfigAttributeAsString(d, "root_password_wo")
15361535
} else if _, ok := d.GetOk("root_password"); ok {
@@ -2184,6 +2183,9 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e
21842183
if err := d.Set("maintenance_version", instance.MaintenanceVersion); err != nil {
21852184
return fmt.Errorf("Error setting maintenance_version: %s", err)
21862185
}
2186+
if err := d.Set("psc_service_attachment_link", instance.PscServiceAttachmentLink); err != nil {
2187+
return fmt.Errorf("Error setting psc_service_attachment_link: %s", err)
2188+
}
21872189
if err := d.Set("available_maintenance_versions", instance.AvailableMaintenanceVersions); err != nil {
21882190
return fmt.Errorf("Error setting available_maintenance_version: %s", err)
21892191
}
@@ -2571,6 +2573,10 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{})
25712573
instance.NodeCount = int64(d.Get("node_count").(int))
25722574
}
25732575

2576+
if _, ok := d.GetOk("psc_service_attachment_link"); ok {
2577+
instance.PscServiceAttachmentLink = d.Get("psc_service_attachment_link").(string)
2578+
}
2579+
25742580
// Database Version is required for all calls with Google ML integration enabled or it will be rejected by the API.
25752581
if d.Get("settings.0.enable_google_ml_integration").(bool) || len(_settings["connection_pool_config"].(*schema.Set).List()) > 0 {
25762582
instance.DatabaseVersion = databaseVersion

mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5800,6 +5800,11 @@ func verifyPscOperation(resourceName string, isPscConfigExpected bool, expectedP
58005800
if !ok || allowedConsumerProjects != len(expectedAllowedConsumerProjects) {
58015801
return fmt.Errorf("settings.0.ip_configuration.0.psc_config.0.allowed_consumer_projects property is not present or set as expected in state of %s", resourceName)
58025802
}
5803+
5804+
pscServiceAttachmentLink, ok := resourceAttributes["psc_service_attachment_link"]
5805+
if !ok || pscServiceAttachmentLink == "" {
5806+
return fmt.Errorf("psc_service_attachment_link property value is empty")
5807+
}
58035808
}
58045809

58055810
return nil

0 commit comments

Comments
 (0)