Go-gin GROM connect gcloudsql on Google Cloud App Engine
Summarized form tutorials:
- Go Application deployment on Google App engine flexible environment
- Connecting to Cloud SQL (Postgres) from a Go web app
Create app.yaml and Dockerfile in app root.
Find instance name
For example: your_project_id:east-2:my_instance_name
Instances name can be found in:
Google Cloud Dashboard -> SQL -> Instances.
It looks like:
In the table, find it in column ‘Instance connection name’.
Copy and paste it. Should work.
Updated golang version to 1.19
# FOR GAE Flexible Environment Custom Runtime
Server port of Go-gin
Server port should be 8080.
If you use config file, alter it accordingly.
router.Run(":" + config.Server.Port)
The host here should be like:
Pay attention to the leading /cloudsql/ part.
You don’t need Google Cloud Proxy to connect, as far as your App Engine and SQL instances are in a same project.
gcloud app deploy
It should works.