diff --git a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl index 1a0c683d01d4..41e8a1a2d1a2 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl +++ b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance.go.tmpl @@ -1031,8 +1031,30 @@ is set to true. Defaults to ZONAL.`, "dns_name": { Type: schema.TypeString, Computed: true, - Description: `The dns name of the instance.`, + Description: `The instance-level dns name of the instance for PSC instances or public IP CAS instances.`, }, + "dns_names": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Computed: true, + }, + "connection_type": { + Type: schema.TypeString, + Computed: true, + }, + "dns_scope": { + Type: schema.TypeString, + Computed: true, + }, + + }, + }, + Description: `The list of DNS names used by this instance. Different connection types for an instance may have different DNS names. DNS names can apply to an individual instance or a cluster of instances.`, + }, "restore_backup_context": { Type: schema.TypeList, Optional: true, @@ -1833,6 +1855,9 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e if err := d.Set("dns_name", instance.DnsName); err != nil { return fmt.Errorf("Error setting dns_name: %s", err) } + if err := d.Set("dns_names", flattenDnsNames(instance.DnsNames)); err != nil { + return fmt.Errorf("Error setting dns_names: %s", err) + } d.SetId(instance.Name) return nil @@ -2611,6 +2636,23 @@ func flattenIpAddresses(ipAddresses []*sqladmin.IpMapping) []map[string]interfac return ips } + +func flattenDnsNames(dnsNames []*sqladmin.DnsNameMapping) []map[string]interface{} { + var dns []map[string]interface{} + + for _, mapping := range dnsNames { + data := map[string]interface{}{ + "name": mapping.Name, + "connection_type": mapping.ConnectionType, + "dns_scope": mapping.DnsScope, + } + + dns = append(dns, data) + } + + return dns +} + func flattenServerCaCerts(caCerts []*sqladmin.SslCert) []map[string]interface{} { var certs []map[string]interface{} diff --git a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_meta.yaml b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_meta.yaml index bcbb45b0ee6d..003e20c08d5f 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_meta.yaml +++ b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_meta.yaml @@ -14,6 +14,7 @@ fields: - field: 'database_version' - field: 'deletion_protection' - field: 'dns_name' + - field: 'dns_names' - field: 'encryption_key_name' - field: 'first_ip_address' - field: 'instance_type' diff --git a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go.tmpl b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go.tmpl index 5049a80a85a4..7840e3261925 100644 --- a/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go.tmpl +++ b/mmv1/third_party/terraform/services/sql/resource_sql_database_instance_test.go.tmpl @@ -2929,6 +2929,9 @@ func TestAccSqlDatabaseInstance_useCasBasedServerCa(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_mode", "GOOGLE_MANAGED_CAS_CA"), resource.TestCheckResourceAttr(resourceName, "settings.0.ip_configuration.0.server_ca_pool", ""), + resource.TestCheckResourceAttr(resourceName, "dns_names.#", "1"), + resource.TestCheckResourceAttr(resourceName, "dns_names.0.connection_type", "PUBLIC"), + resource.TestCheckResourceAttr(resourceName, "dns_names.0.dns_scope", "INSTANCE"), ), }, { diff --git a/mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown b/mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown index 7ddc19dd8a53..9cbb8c5d91fe 100644 --- a/mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown +++ b/mmv1/third_party/terraform/website/docs/r/sql_database_instance.html.markdown @@ -583,6 +583,16 @@ connection strings. For example, when connecting with [Cloud SQL Proxy](https:// * `dns_name` - The DNS name of the instance. See [Connect to an instance using Private Service Connect](https://cloud.google.com/sql/docs/mysql/configure-private-service-connect#view-summary-information-cloud-sql-instances-psc-enabled) for more details. +* `dns_names` - The list of DNS names used by this instance. Different connection types for an instance may have different DNS names. DNS names can apply to an individual instance or a cluster of instances. + +* `dns_names.0.name` - The DNS name. + +* `dns_names.0.connection_type` - The connection type of the DNS name. Can be either `PUBLIC`, `PRIVATE_SERVICES_ACCESS`, or `PRIVATE_SERVICE_CONNECT`. + +* `dns_names.0.dns_scope` - The scope that the DNS name applies to. + + * An `INSTANCE` DNS name applies to an individual Cloud SQL instance. + * `service_account_email_address` - The service account email address assigned to the instance.