The Simplest Way to Make Cloud SQL and Ec2 Instances Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair cloud sql and ec2 instances when compute runs on AWS while databases stay on Google Cloud. This setup lets apps on virtual machines read and write managed relational data across clouds. Multi-cloud setups happen during company mergers or phased cloud migrations. An engineering team might keep legacy compute on AWS while moving data to Google Cloud. Getting the link between these two platforms right takes clear network and identity rules. How cloud sql and ec2 instances share data a

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 pair cloud sql and ec2 instances when compute runs on AWS while databases stay on Google Cloud. This setup lets apps on virtual machines read and write managed relational data across clouds.

Multi-cloud setups happen during company mergers or phased cloud migrations. An engineering team might keep legacy compute on AWS while moving data to Google Cloud. Getting the link between these two platforms right takes clear network and identity rules.

How cloud sql and ec2 instances share data and identity

Data flows between an AWS virtual machine and a Google database over encrypted links. Teams often link their virtual private networks using a site-to-site VPN or a dedicated interconnect. If they use public IP paths, they must lock down source addresses and enforce TLS.

Once the network path works, the app or user on the virtual machine must log in. Cloud SQL for PostgreSQL is a managed service, so customers cannot create true superuser accounts. Instead, a Google system user holds full superuser rights on the database.

Customers use a custom admin role that grants partial admin privileges for daily setup tasks. This role can create extensions, event triggers, replication users, and replication publications or subscriptions. The default admin user belongs to this role and can create roles, create databases, and log in.

That default admin user starts with no password, so you must set one before logging in. Still, your compute workloads should never log in with that admin user. Instead, create separate database users with limited read or write permissions for each workload.

Common failure modes across cloud boundaries

Cross-cloud setups often fail because teams take shortcuts with network rules and shared credentials. Opening database firewall rules to broad IP ranges exposes the instance to outside attacks. If an AWS machine gets a new IP address, wide firewall rules leave old addresses open.

Shared database accounts create an even bigger risk for engineering teams. Developers often put a single admin password onto an AWS machine for quick debugging. Soon, every script and engineer on that host uses the same high-privilege database login.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

When someone runs a bad query or drops a table, the database logs show one shared name. You cannot tell which person or script ran the command from the virtual machine. Also, rotating that password breaks every app on the host at the same time.

Scoping roles and network paths for production

To fix these issues, separate human database tasks from automated app traffic. Give each app on your virtual machine its own database role with narrow table rights. If a worker only reads billing rows, grant select rights on that table alone.

Reserve the Google custom admin role for schema changes and extension setup. Never store those admin credentials on compute hosts where normal users can read them. Remove default passwords from deployment scripts and rotate app secrets on a set schedule.

On the network side, route traffic over private RFC 1918 addresses across an encrypted tunnel. Restrict security groups on the virtual machine so only approved processes can reach the database port. Finally, mask sensitive fields like emails, phone numbers, card numbers, and national IDs in query results.

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

Can I get full PostgreSQL superuser rights on a Google managed database?

No, customers cannot create or use accounts with full superuser attributes on this managed service. You get a custom admin role that lets you manage extensions, triggers, and replication tasks.

Should my AWS compute workloads use the default database admin account?

No, the default admin account has broad rights to create roles and databases. Create dedicated roles for each app with only the read or write permissions it needs.

How do I protect personal data when engineers query the database from a virtual machine?

Use data masking to rewrite matched fields like emails, phone numbers, and card numbers in results. Combine this with individual user identities so every query ties back to a specific person.

Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.

The query runs. The emails stay hidden.