The Simplest Way to Make App Of Apps and Cloud SQL Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Running app of apps and cloud sql together connects declarative GitOps patterns to managed databases. This pairing lets platform teams deploy child apps that read and write database records. In a GitOps setup, one root app manages a group of child apps. Each child app runs a distinct service in your cluster. Many of these child services need a backend database to store state. Cloud SQL for PostgreSQL provides that managed database engine. When you link them well, each service gets the exact dat

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.

Running app of apps and cloud sql together connects declarative GitOps patterns to managed databases. This pairing lets platform teams deploy child apps that read and write database records.

In a GitOps setup, one root app manages a group of child apps. Each child app runs a distinct service in your cluster. Many of these child services need a backend database to store state. Cloud SQL for PostgreSQL provides that managed database engine. When you link them well, each service gets the exact database role it needs.

How app of apps and cloud sql handle identity and data

To make app of apps and cloud sql work well, start with identity. Each child app in your cluster runs under its own service account. That service account should map to a specific database user with limited permissions. Data flows from the child app over a private network path to the database.

Cloud SQL for PostgreSQL is a managed service with strict role boundaries. Customers cannot create or use database accounts with true superuser attributes. A system user managed by Google, called cloudsqladmin, holds the real superuser rights. Customers cannot delete or change Cloud SQL system roles or users.

Instead, admins use the cloudsqlsuperuser role, which has some superuser privileges. It can create extensions that need superuser rights and set up event triggers. It can also create replication users, publications, and subscriptions. The default admin user, named postgres, belongs to this cloudsqlsuperuser role. It has rights to create roles, create databases, and log in. Still, it does not have superuser or replication attributes. You must set a password for the postgres user before you log in.

When a child app deploys, it may run a schema migration job first. That migration job might need the cloudsqlsuperuser role to add database extensions. Once the migration finishes, the main app workload should use a weaker role. The daily app role only needs rights to read and write specific tables.

Common failure modes and how to scope database roles

The biggest mistake with this setup is sharing one database account everywhere. Teams often put the default postgres user credentials into a shared cluster secret. Then every child app in the root app tree uses that same secret. If one child app has a bug, it can drop tables for other apps.

DPoP (Demonstration of Proof-of-Possession) + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Broad tokens and shared service accounts also break your audit trail. When ten apps log in as the postgres user, database logs look identical. You cannot tell which child app ran a slow or harmful query. Unlogged manual queries make this problem even worse during an outage. Engineers often connect from their laptops using the same shared admin credentials.

To fix this, give every child app its own database role and schema. Use your GitOps workflow to declare a unique service account per child app. Map each service account to a database role that only touches its own tables. Keep the cloudsqlsuperuser role locked away from normal app workloads.

You should also restrict network paths between your cluster and the database instance. Only allow traffic from namespaces that run apps needing database state. For human database checks, avoid handing out static passwords to the postgres account. Apply data masking to rewrite matched fields like emails, phone numbers, and card numbers. Masking can also rewrite national IDs in query results during live checks.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Can a child app use a true PostgreSQL superuser in Cloud SQL?

No, customers cannot create or access users with true superuser attributes in Cloud SQL. Google reserves superuser rights for the cloudsqladmin system user. You can assign the cloudsqlsuperuser role if an app needs to create extensions.

Should all child apps share the default postgres database user?

No, sharing the default postgres user across child apps creates a major security risk. The postgres user belongs to cloudsqlsuperuser and can create roles and databases. Give each child app its own restricted database user with minimal table rights.

How should we handle schema migrations in an app of apps setup?

Run schema migrations as a separate job before the main child app starts. Give the migration job a role that can alter schemas or add extensions. Give the running app a basic role that only reads and writes data.

The query runs. The emails stay hidden.