App engine config:
instance_class: F1
automatic_scaling:
min_idle_instances: automatic
max_idle_instances: automatic
min_pending_latency: automatic
max_pending_latency: automatic
NodeJs application running: (i) Apollo server, (ii) Express, (iii) Knex
Steps:
- Get the Public IP Address of Cloud SQL Instance
- Get the Connection Name of Cloud SQL Instance
- Set the Connection Name of the Cloud SQL Instance in
app.yaml - Set the Public IP Address of the Cloud SQL Instance in
index.tsof client
index.ts
// @note Using Knex
const db = await initDatabase({
client: 'pg',
connection: {
host: args['blockchain-db-host'],
port: args['blockchain-db-port'],
database: args['blockchain-db-database'],
user: args['blockchain-db-user'],
password: args['blockchain-db-pass'],
},
})
N.B.
Also get Username, Password, and set them in index.ts, also Port in index.ts used as 5432 as Cloud SQL Instance is a Postgres database.
app.yaml
beta_settings:
cloud_sql_instances: <project>:<region>:<sql-instance>=tcp:5432
N.B.
The beta_settings once deployed via gcloud app deploy is not reflected in config file on Google App Engine. Also, I am not familiar with the Unix socket methodology, I am assuming that 5432 should also be used as the PORT when setting up the App engine's cloud proxy connection.