Connect
--instance takes the name of the instance. cloudsql is the default service, so you can leave
out --service.
bqto gives you a port forward. The local port is the port of the instance plus 10000, so 5432
becomes 15432. The try: line gives a command for the client:
Clients
When you run a command through the session with
-- CMD, the command gets these variables:
What it needs
- The API
sqladmin.googleapis.comin the service project. - The role
roles/cloudsql.viewerin the service project, together with the roles that every session needs. See Permissions.
Connection logs
To match a connection in the database to a session, turn on the connection log of the instance. These flags come from Google’s documentation and were not tested live.Check the server certificate
With--endpoint, bqto prints a try: line with sslmode=require. That
mode encrypts the connection, but it does not check a certificate. To check the certificate,
download the server CA of the instance into server-ca.pem.
With the default per-instance CA, each instance has its own CA, so it is enough to check the CA.
The certificate holds the DNS name of the instance only on Private Service Connect instances.
host and connects to hostaddr: