Google Cloud SQL — Tips & Tricks

Konstantin Tarkus
6 min readSep 5, 2020
Google Cloud SQL, PostgreSQL Edition

When creating a new Cloud SQL instance…

Ensure that the instance name is picked wisely. You may find it helpful if it remains short, and contains the Cloud SQL edition (MySQL, PostgreSQL, SQL Server) and version number. For example, pg12.

https://console.cloud.google.com/sql/

Down the road, when you’ll be upgrading it to the newer version, you would create a separate Cloud SQL instance (e.g. pg14) backup data from the previous database instance and restore it in the new one. Note that renaming a Cloud SQL instance (ID) is not possible, as well as changing its region. When you delete a Cloud SQL instance, you will not be able to create a new instance with the same name, at least not within the next couple of months.

Most likely you will be using a separate GCP project for each deployment environment ( prod, stading, test, dev). In which case, adding the environment (slug) into the instance name is not necessary.

Enable access from public IP addresses solely for development and administration convenience. Whitelist IP addresses (or, IP ranges) from which it would be allowed to access the database. You would also need to restrict access to the database without a valid SSL certificate.

If unsure, pick “micro” database instance size (shared vCPU, 0.6 GB RAM, $8/month), it should handle a small web application payload just fine unless something is misconfigured.

Once the database instance (VM) is created, go to its settings > Connections, disable unsecured connections, and download client and server SSL certificates to your web application project.

When creating a database…

During development, it’s totally fine to use a single instance of Cloud SQL, just create a separate database per…

Konstantin Tarkus

Empowering startups with cutting-edge expertise: software architecture, optimal practices, database design, web infrastructure, and DevOps mastery.