Connecting Node.js app on Google Cloud App Engine to a Google Cloud SQL instance

I have a Node app which uses MySQL, connecting via a config json:

{
    "client": "mysql",
    "connection": {
        "host": "something",
        "user": "something",
        "password": "something",
        "database": "daimonion-db",
        "debug": false
    }
}

I've created a Google Cloud Platform SQL instance. I'm seeing an IP address and instance connection name.

I've also deployed the Node app to Google Cloud App Engine in a flexible environment.

How do I connect the Node app to the SQL instance? I'm seeing this explanation: https://cloud.google.com/sql/docs/mysql/connect-app-engine which tells me to add a settings string to my app.yaml to connect with either a Unix domain socket or TCP connection, but how do I connect to these from my Node app?

#node-js #sql

6 Likes4.40 GEEK