I have a Google Cloud project with an app and a Cloud SQL Instance. SQL requests from the app time out. Private IP connectivity is enabled. If I explicitly add the app instances' IPs to the SQL Instance's public authorized networks, it works. This is obviously a bad solution since these IPs change on every deployment. How do I permanently grant access to the app?
1 Answers
3
votes
Private IP's are only accessible by other services on the same Virtual Private Cloud (VPC). App Engine apps don't currently have access to VPC networks.
Edit: App Engine has recently released Serverless VPC Access, meaning that the can now be configured to connect via Private IP.
App Engine Standard does provide a unix domain socket to interface with Cloud SQL instances. Just tell your app to use the socket at /cloudsql/<INSTANCE_CONNECTION_NAME>; (with your instance's connection name), and it should be able to connect. If you are using a cross product or cross regional setup, there are more instructions here.
if (process.env.INSTANCE_CONNECTION_NAME && process.env.NODE_ENV === 'production') {. Can you try to remove this condition, and in theconfigdictionary, directly addsocketPath:``/cloudsql/${process.env.INSTANCE_CONNECTION_NAME}``;(there is an extra ` in this last line due formatting, you should remove it) - Joan Grau Noël