How to Configure Cloud SQL Revoke Access
To perform a cloud sql revoke access task, remove cloud roles and drop database privileges. You must also stop active sessions so the user loses all database rights right away. Teams often grant the default admin role to every developer for fast setup. Broad roles let users read or change sensitive tables across the whole database instance. When an engineer changes teams, removing their login without fixing object ownership causes errors. How cloud sql revoke access works in PostgreSQL Cloud
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.
To perform a cloud sql revoke access task, remove cloud roles and drop database privileges. You must also stop active sessions so the user loses all database rights right away. Teams often grant the default admin role to every developer for fast setup. Broad roles let users read or change sensitive tables across the whole database instance. When an engineer changes teams, removing their login without fixing object ownership causes errors.
How cloud sql revoke access works in PostgreSQL
Cloud SQL for PostgreSQL is a managed service with strict role rules. Customers cannot create or use accounts with true superuser attributes on the instance. A Google-managed system user named cloudsqladmin holds the actual superuser privileges. Customers cannot delete or modify these built-in system roles or users.
Instead, you assign users the cloudsqlsuperuser role for high-level tasks. This role grants specific rights like creating extensions, event triggers, and replication users. The default postgres admin user belongs to this group by default. That default user starts without a password, so you must set one before logging in. It holds role creation, database creation, and login rights, but lacks true superuser status.
When you remove a user, you must check both cloud and database layers. Removing a cloud identity stops new logins at the project level. Inside the database, you still need to revoke table rights and role memberships. PostgreSQL blocks you from dropping a role that still owns database schemas or tables. You must reassign those objects to another admin role before you drop the user. You also need to end open sessions, because active users keep running queries until disconnected.
Why role revocation is not enough for active sessions
Native role removal works well when someone leaves the company or switches teams. It stops deleted accounts from starting new sessions on your database instance. Still, native roles only control who can log in and what objects they own. They do not inspect what individual statements do during an active session.
Engineers on call often need temporary rights to fix a broken production table. If you grant them the cloudsqlsuperuser role, they can read or alter every table. You have to remember to revoke those broad rights once the ticket closes. If you forget, that account keeps permanent write rights across the database.
Customer Support Access to Production + SQL Query Filtering: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Shared admin accounts make this problem even worse for security teams. When five engineers share the default postgres user, you cannot revoke one person alone. Changing the password breaks scripts and locks out the other four engineers. Native roles also cannot rewrite sensitive fields like emails or phone numbers in query results. Anyone with read rights on a table gets the full data in every row.
Steps to clean up overprivileged database roles
Start by listing every account that belongs to the cloudsqlsuperuser group today. Remove human users from that group if they only need to read app tables. Create narrow roles that grant read or write rights on specific schemas instead. Before you drop an old user, transfer their owned tables to a shared team role. Next, revoke their schema rights and remove their login permission inside the database. Last, kill any active sessions tied to that username so the change takes effect now.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev sits inline in the protocol beside each supported service as an open-source proxy, a sidecar for your database or API. For every query or command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human approval.
First, hoop.dev guardrails block banned queries before they run or hold risky ones for review, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
Can I delete the cloudsqladmin user to lock down my instance?
No, cloudsqladmin is a Google-managed system account that holds true superuser privileges. Customers cannot delete or modify Cloud SQL system roles or users.
Why does PostgreSQL block me from dropping a revoked user?
PostgreSQL will not drop a role that still owns tables, views, or schemas. You must transfer ownership of those objects and revoke all privileges before dropping the user.
Does the default postgres user have full superuser rights in Cloud SQL?
No, the default postgres user belongs to the cloudsqlsuperuser role instead. It can create roles and databases, but it lacks true superuser and replication attributes.
Related guides
In this post