-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Ability to connect to Google Cloud SQL from App Engine #103
Comments
I think it would be necessary to re-implement Google's client authentication code for Cloud SQL in Swift; here's a Java example. Note that it is already possible to connect to Cloud SQL from Kubernetes Engine, however, through the Cloud SQL Proxy sidecar. I am successfully using that approach in production. |
After doing some additional research and looking into the ruby implementation, the socket should be something like databases.add(database:
PostgreSQLDatabase(config:
PostgreSQLDatabaseConfig(
hostname: Environment.get("POSTGRES_SOCKET_PATH") ?? Environment.get("POSTGRES_HOST") ?? "localhost",
port: Int(Environment.get("POSTGRES_PORT") ?? "5432") ?? 5432,
username: Environment.get("POSTGRES_USER") ?? "default",
database: Environment.get("POSTGRES_DATABASE") ?? "default_database",
password: Environment.get("POSTGRES_PASSWORD")
)
),
as: .psql) My env variable With the current implementation of Postgres' driver, that socket form wouldn't work, right? |
All that was needed to connect to the Postgres database was a unix socket, which I had originally thought, but I was missing the socket file at the end of the path. The full path should look like this |
Wow, I didn’t know that. Does App Engine auto-mount a virtual file system in that location? Anyway, glad to hear that adding Postgres support to the driver was useful. |
The virtual file system, I'm not sure of. I assume it has something mounted there for you to gain access to. |
Did you ever see a similar error when trying to use the unix socket like |
This is the current error I'm having, has anyone had success connecting using unix sockets? |
Google Cloud does some weird things when trying to connect to an SQL instance through App Engine. Connecting directly via an IP address is blocked from App Engine, so the way you have to connect is via a socket/proxy.
Here is a bit more info on the whole thing: https://cloud.google.com/sql/docs/postgres/sql-proxy
I've tried just about everything you can possibly think of.
Here is a bit more info regarding connecting to an SQL instance from App Engine.
https://cloud.google.com/sql/docs/postgres/connect-app-engine
The text was updated successfully, but these errors were encountered: