Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Automatically find the remote sql-proxy-server address from the org/db/branch combination #32

@fatih

Description

@fatih

Currently, if we run the sql-proxy-client on a localhost, we need to pass the remote address we want to connect. Here is an example command:

sql-proxy-client
  --token "$(cat ~/.config/planetscale/access-token)" 
  --instance "org/db/branch"
  --remote-addr ac001fde9cdb746988cf56648d20f3d0-cc3d7d661b5e5955.elb.us-east-1.amazonaws.com:3306

The user shouldn't pass the remote sql-proxy-server address. The tool should be run in this form:

sql-proxy-client 
  --token "$(cat ~/.config/planetscale/access-token)" 
  --instance "org/db/branch" 

The significant bit is, sql-proxy-client is already authenticated to our API. It should find a way to retrieve the remote address and connect to it automatically. There could be multiple ways to get this remote address:

  1. The API could embed the remote address of sql-proxy-server into the cert as metadata (SAN or as a subject field). Once the sql-proxy-client receives the signed cert, it'll read the metadata and used the remote address to connect.
  2. We could use the existing /organization/:org/databases/:db/branches/:branch/status endpoint to fetch the current vtgate address. We could make sure that the returned address is also compatible with sql-proxy-server (cc @enisoc)
  3. We could use a new endpoint to return the sql-proxy-server's remote address.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions