I want to connect to my GCP Cloud SQL postgres DB from my local nodejs program.
Currently the way i am able to do it is make the DB instance public facing behind authentication and Add my IP address to the Allowed network section.
This seems cumbersome because if i use a VPN or switch to different network those IPs will not be able to access the instance.
So rather i would prefer if node application is able to use my google credentials file stored in my local and understand i have access to the CloudSQL instance.
For other google services i tend to use google auth library but i am not able to find any google recommended way to using an SDK which does this authentication and allows my connection.
How should i use my credentials and get access to the CloudSQL from my local machine then?
Tried reading around the documentation. They explain all Apps in the respective projects have access to the CloudSQL. But don't talk about user account access, or any SDK specific to nodeJS
Our recommendation is to use the Cloud SQL Node Connector (just recently release to Public Preview): https://github.com/GoogleCloudPlatform/cloud-sql-nodejs-connector.
We're working on putting this into the documentation, but for now the README on GitHub above should have all the details. Feel free to file issues if something isn't clear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With