A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/sql/docs/postgres/custom-dns-name below:

Set up a custom DNS name for a Cloud SQL instance | Cloud SQL for PostgreSQL

Set up a custom DNS name for a Cloud SQL instance

Stay organized with collections Save and categorize content based on your preferences.

This page describes how to set up a custom domain name system (DNS) name for your Cloud SQL instance.

Overview

You can configure a Cloud SQL instance so that your applications can connect using a custom DNS name managed by your organization. If you want to use a custom DNS name to connect to a Cloud SQL instance instead of using an IP address, then configure a custom subject alternative name (SAN). You can configure a custom SAN when you create or update an instance.

When you add a custom DNS name as a custom SAN configuration to your instance, Cloud SQL inserts the custom DNS name to the SAN field of the server certificate of the instance. This customization lets you use the custom DNS name with hostname validation securely. You can add a comma-separated list of up to three custom DNS names to the custom SAN configuration. For security reasons, you can use a custom SAN configuration only for instances that you configure with CUSTOMER_MANAGED_CAS_CA as the server CA mode.

After you configure the custom DNS name for your instance, you can use that custom DNS name to connect your database clients or applications, including Cloud SQL Language Connectors and the Cloud SQL Auth Proxy.

Workflow

To set up a custom DNS name for an instance, do the following:

  1. Create an instance configured with customer-managed CA.
  2. Add custom SAN values to the instance. The custom SAN values are inserted into the SAN field of the server certificate of the instance.
  3. Determine the IP address of the instance.
  4. Create custom DNS records for your instance.
  5. Connect to the instance using the custom DNS name.
Before you begin

Before you set up a custom DNS name for your instance, make sure you have the required roles and permissions.

If you are creating a new Cloud SQL instance, then to use custom SAN, your instance must also use a customer-managed certificate authority (CA) for its server CA mode.

Create an instance with custom SAN values

To create an instance with custom SAN values, use the following gcloud sql instances create command:

gcloud
gcloud sql instances create "INSTANCE_NAME" \
  --database-version=DATABASE_VERSION \
  --project=PROJECT_ID \
  --region=REGION \
  --server-ca-mode=CUSTOMER_MANAGED_CAS_CA \
  --server-ca-pool=projects/PROJECT_ID_CAS/locations/REGION/caPools/CA_POOL_ID
  --custom-subject-alternative-names=CUSTOM_DNS_NAME

Make the following replacements:

Add or update custom SAN values for an instance

To add or update custom SAN values for an existing instance, do the following:

gcloud
gcloud sql instances patch INSTANCE_NAME \
  --custom-subject-alternative-names=CUSTOM_DNS_NAME
Caution: If you're updating an instance that already has custom SAN values, then specify the existing custom SAN values or the existing values will be replaced.

Make the following replacements:

Clear all custom SAN values from an instance

To clear all custom SAN values from an instance, do the following:

gcloud
gcloud sql instances patch INSTANCE_NAME \
  --clear-custom-subject-alternative-names

Replace INSTANCE_NAME with the name of the Cloud SQL instance that you want to update.

Create custom DNS records

Before you can connect to the instance using the custom DNS name with your clients and applications, set up the mapping between the DNS name and the IP address. This mapping is known as DNS resolution. If you are connecting privately, then create the DNS record in a private DNS zone in the corresponding Virtual Private Cloud (VPC) network.

To create custom DNS records for your instance, do the following:

  1. Retrieve the IP address for your instance. Run the following command:

    gcloud sql instances describe INSTANCE_NAME \
     --project=PROJECT_ID

    Make the following replacements:

  2. In the response, look for the ipAddresses: field.

    For example:

    ipAddresses:
    - ipAddress: 192.0.2.4
      type: PRIVATE
    

    You can retrieve the private IP address for an instance configured for private services access, Private Service Connect, or both.

    Warning: For security reasons, we don't recommend setting up custom DNS records for the public IP address of an instance.
  3. Add two DNS records to a DNS zone used by your application. You can use a DNS server that you manage yourself or the Cloud DNS private zone used by your application.

    Standard database clients use the A record to look up the IP address to make the connection. Cloud SQL Language Connectors and the Cloud SQL Auth Proxy use the TXT record to look up the instance connection name.

    For example, the connection string for your instance is my-project:region:my-instance, but you want to connect using the DNS name prod-db.mycompany.example.com. If the IP address of the instance on your company network is 192.0.2.4, then create the following DNS records:

    Record type: A
    Name: prod-db.mycompany.example.com
    Value: 192.0.2.4
    TTL: 600
    
    Record type: TXT
    Name: prod-db.mycompany.example.com
    Value: my-project:region:my-instance
    TTL: 600
    
Connect to an instance using a custom DNS name

When you connect to the Cloud SQL for PostgreSQL instance, configure the custom DNS name as the hostname and enable server identity verification in your client.

For example, when using the psql client, specify the flag sslmode=verify-full. Other PostgreSQL client drivers have similar configuration flags.

If you're connecting to a private Cloud SQL instance from an external network, then you must configure your Cloud SQL instance and its Virtual Private Cloud (VPC) network to permit external connections and to let Cloud DNS communicate with on-premises systems. For more information about this configuration, see Connect from an external source and Configure DNS for on-premises systems.

Limitations What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-02 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-02 UTC."],[],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4