Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for DNS names with Connector #1204

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open

Conversation

jackwotherspoon
Copy link
Collaborator

@jackwotherspoon jackwotherspoon commented Nov 28, 2024

The Connector may be configured to use a DNS name to look up the instance
name instead of configuring the connector with the instance connection name directly.

Add a DNS TXT record for the Cloud SQL instance to a private DNS server
or a private Google Cloud DNS Zone used by your application. For example:

  • Record type: TXT
  • Name: prod-db.mycompany.example.com – This is the domain name used by the application
  • Value: my-project:my-region:my-instance – This is the instance connection name

Configure the Connector to use a DNS name via setting resolver argument to DnsResolver:

from google.cloud.sql.connector import Connector, DnsResolver

connector = Connector(resolver=DnsResolver)

Call connector.connect with DNS domain name instead of instance connection name:

conn = connector.connect(
    "prod-db.mycompany.example.com",  # using DNS domain name
    "pymysql",
     # ... insert other kwargs
)

Part of #1169

@jackwotherspoon jackwotherspoon self-assigned this Nov 28, 2024
@jackwotherspoon jackwotherspoon changed the title WIP: add support for DNS names with Connector feat: add support for DNS names with Connector Dec 2, 2024
@jackwotherspoon jackwotherspoon marked this pull request as ready for review December 2, 2024 21:23
@jackwotherspoon jackwotherspoon requested a review from a team as a code owner December 2, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant