The Simplest Way to Make Cloud SQL and Google Compute Engine Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use cloud sql and google compute engine to run web apps with managed databases. The virtual machine runs your app code while the managed database stores your state. This pairing lets you separate compute tasks from data storage in production. Your compute instances can scale up or down based on web traffic. Meanwhile, the database service handles backups, patches, and disk management for you. Yet linking these two services takes careful work around network paths and user roles. How clou

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams use cloud sql and google compute engine to run web apps with managed databases. The virtual machine runs your app code while the managed database stores your state.

This pairing lets you separate compute tasks from data storage in production. Your compute instances can scale up or down based on web traffic. Meanwhile, the database service handles backups, patches, and disk management for you. Yet linking these two services takes careful work around network paths and user roles.

How cloud sql and google compute engine share data and identity

Data moves between your virtual machines and your database over private or public networks. Most teams put both services inside the same virtual private cloud network. This setup keeps database traffic off the public internet and lowers latency.

Before an app or engineer can read data, the database must check their identity. You can log in with standard database passwords or cloud identity accounts. Inside Cloud SQL for PostgreSQL, the platform restricts top-level database roles to keep the service stable. Customers cannot create or use accounts with full superuser attributes on the instance. A Google-managed system user named cloudsqladmin holds the actual superuser rights on the database. Customers cannot delete or change these built-in system roles or users.

Instead, the service gives you a custom admin role called cloudsqlsuperuser. The default postgres admin user belongs to this group and comes without a password. You must set a password on that default user before you can log in. This default user can create roles, create databases, and log in. It does not have full superuser or replication attributes on its own. Still, the cloudsqlsuperuser role grants some high-level rights to your admin team. Users with this role can add extensions that need high rights and create event triggers. They can also create replication users, publications, and subscriptions for data sync.

Common failure modes and how to scope access

Many teams make mistakes when they link compute instances to database instances. The biggest risk is putting one shared database password on every virtual machine. If an attacker compromises one machine, they get that shared password right away. Worse, teams often use the default postgres admin account for normal app traffic. That gives a web app the power to create new roles or drop tables.

End-to-End Encryption + SQL Query Filtering: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Human access from compute instances causes major audit blind spots too. Engineers often log into a virtual machine to run live database queries during an outage. If five engineers share one database user, your logs show only that single role name. You cannot tell which person ran a bad delete query or read sensitive rows. Also, query results often return raw customer emails, phone numbers, or card numbers.

To fix this, give each compute service its own database user with narrow rights. An app that only reads product data should only have select rights on those tables. Reserve the cloudsqlsuperuser role for setup tasks like adding extensions or setting up replication. Never put admin credentials on a normal compute instance where apps run.

Next, lock down the network path between your compute nodes and your database. Allow traffic only from the specific private IP addresses of your app machines. Do not open the database port to the whole internal network or every subnet. Finally, separate human debugging sessions from automated app traffic so every query maps to a person.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Does the default postgres user have full superuser rights in Cloud SQL?

No, customers cannot use true superuser accounts in this managed database service. The default postgres user belongs to the cloudsqlsuperuser role and can create roles and databases. A Google-managed user named cloudsqladmin holds the real superuser privileges on the system.

What can a user with the cloudsqlsuperuser role do?

This role lets admins create extensions that need high privileges and set up event triggers. It also lets users create replication accounts, publications, and subscriptions. Still, users with this role cannot change or delete Google system roles.

Why should apps on compute instances avoid using the default admin user?

The default admin user can create databases, add roles, and change replication settings. If an app uses this account, a single code bug or breach can ruin your whole database. Always create a separate user with only the table rights your app needs.

The query runs. The emails stay hidden.