How to Configure Cloud SQL Replication User
You set up a cloud sql replication user by logging in with an admin account that holds the cloudsqlsuperuser role. You then grant the replication privilege to a new database account and give it read permissions on the source tables. Teams often take a shortcut and use the default admin account for data sync tasks. This choice gives sync tools wide rights to drop tables, change schemas, or read private rows across the whole instance. How a cloud sql replication user works in PostgreSQL Cloud S
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.
You set up a cloud sql replication user by logging in with an admin account that holds the cloudsqlsuperuser role. You then grant the replication privilege to a new database account and give it read permissions on the source tables. Teams often take a shortcut and use the default admin account for data sync tasks. This choice gives sync tools wide rights to drop tables, change schemas, or read private rows across the whole instance.
How a cloud sql replication user works in PostgreSQL
Cloud SQL for PostgreSQL is a managed database service. Customers cannot create or use accounts with true superuser attributes. Google keeps a system account named cloudsqladmin to hold true superuser rights on the instance. Customers cannot change or delete these system roles.
Instead, you manage the database through the cloudsqlsuperuser role. The default postgres admin user belongs to this role out of the box. It starts without a password, so you must set one before you log in. This default user can create roles, create databases, and log in. Still, it does not hold the replication attribute or true superuser status by default.
Because the default user belongs to cloudsqlsuperuser, it still gets specific high-level privileges. It can add extensions, set up event triggers, and build replication publications and subscriptions. It also has the right to create a dedicated cloud sql replication user.
To set this up, an admin logs in with an account in the cloudsqlsuperuser group. The admin creates a separate role and assigns the replication attribute to it. Next, the admin grants read rights on the specific schemas and tables that need to move. Finally, the admin sets up publications on the source instance or subscriptions on the target instance.
Why you should separate sync roles from admin roles
Splitting your sync role from your daily admin role shrinks your blast radius. When a sync job runs under a dedicated user, it only reads the tables you select. If a pipeline script fails or leaks credentials, the attacker cannot create new users or drop databases. You also get cleaner logs because every sync query shows up under its own account name.
You should also review which tables belong in your publication before starting the stream. Many teams publish all tables by default to save setup time. That habit pushes internal system tables and raw user records to downstream systems that do not need them. A strict setup only grants table read rights on the exact data required by the target database.
User Provisioning (SCIM) + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native database roles solve and what they miss
Native database roles do a good job of controlling who can log in and start a data stream. They stop a sync service from acting like a full database admin. They also let you separate read duties from write duties at the table level.
Still, database roles only check permissions at the table or column level when a session starts. They do not inspect what individual queries do in flight during a live session. Once an engineer or service logs in with read rights on a table, every row comes back in full.
Native roles cannot rewrite sensitive fields like emails, phone numbers, card numbers, or national IDs on the fly. They also cannot pause a risky query for peer approval before it runs on production. If an admin needs temporary rights to fix a broken publication, someone must grant and revoke those roles by hand. Teams often forget to revoke those rights after the fix is done, leaving broad permissions open for months.
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 sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses 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 replication rights in Cloud SQL?
No, the default postgres user does not start with the replication attribute. Still, it belongs to the cloudsqlsuperuser role. As a result, it can create a new user with replication rights or add the attribute.
Can I get true superuser rights to set up logical replication?
No, Cloud SQL does not allow customers to use or create accounts with true superuser attributes. You must use an account with the cloudsqlsuperuser role to create publications, subscriptions, and replication users.
Should I use the cloudsqlsuperuser role for my external sync tool?
No, using cloudsqlsuperuser for a sync tool gives the pipeline too much power over your database. Always create a separate user with only the replication attribute and read access to the required tables.
Related guides
In this post