The Simplest Way to Make AWS Secrets Manager and Cloud SQL Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use aws secrets manager and cloud sql together to store database passwords in AWS. Apps and engineers fetch these stored credentials to log in to managed Google Cloud databases. Multi-cloud teams often run apps in AWS while keeping core data in Google Cloud. A clear workflow keeps database logins safe across both clouds. You must map identity, network paths, and database roles with care. Good role design stops broad access before it starts. How aws secrets manager and cloud sql share cr

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 aws secrets manager and cloud sql together to store database passwords in AWS. Apps and engineers fetch these stored credentials to log in to managed Google Cloud databases.

Multi-cloud teams often run apps in AWS while keeping core data in Google Cloud. A clear workflow keeps database logins safe across both clouds. You must map identity, network paths, and database roles with care. Good role design stops broad access before it starts.

How aws secrets manager and cloud sql share credentials and data

Your workflow starts inside AWS where your apps or tools run. An engineer or app logs in to AWS using an IAM role. That role requests a specific secret from the secret store. AWS checks the policy attached to that IAM identity. If the policy allows it, the store returns the database login details.

Next, the client takes that username and password to reach Google Cloud. The traffic crosses a private network link between the two cloud providers. Then the database checks the password and loads the assigned database role.

In Cloud SQL for PostgreSQL, customers cannot create users with true superuser attributes. Google reserves a system user named cloudsqladmin for full superuser privileges. Customers cannot delete or change these system roles or users. Instead, you can assign the cloudsqlsuperuser role to your admin accounts. This role grants specific high-level privileges like creating extensions and event triggers. It can also create replication users, publications, and subscriptions. The default postgres admin user belongs to this group by default. That default user starts without a password, so you must set one before login. It holds role creation, database creation, and login rights, but lacks true superuser status.

Common failure modes and how to scope roles across clouds

The biggest mistake in this setup is sharing one secret across many people. Teams often put the default postgres user password into a single secret. Then every app and engineer fetches that same admin account to run queries. When someone drops a table, the database logs only show the shared account name. You cannot tell which person or service actually ran the bad command.

AWS Secrets Manager + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static passwords sitting in a store also create rotation headaches across two clouds. If you rotate a password in AWS, the database in Google Cloud must match. A failed rotation locks out production apps right away. Engineers also copy secret values onto their local laptops for quick debugging. Once a password leaves the store, you lose control over who uses it.

To fix this, stop storing the default admin account in shared secrets. Create separate database roles for each app and each team function. Give read-only roles to analysts who only need to inspect tables. Reserve the cloudsqlsuperuser role for rare schema changes and extension setup tasks.

Scope your AWS policies so each app only reads its own secret. Lock down network paths using private routing between your AWS and Google networks. Never expose the database port to the public internet just to simplify cross-cloud logins. Finally, review your sensitive columns like emails, phone numbers, and card numbers. When you add data masking, it rewrites matched fields in query results for safer reads.

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 I store a true PostgreSQL superuser account in AWS Secrets Manager for Cloud SQL?

No, because Cloud SQL is a managed service that blocks customer access to true superuser attributes. You can only store accounts that use the cloudsqlsuperuser role or standard custom roles.

Why is sharing one secret for Cloud SQL a security risk?

Sharing one secret means every engineer and app logs in with the same database username. Database audit logs will show that single shared user, hiding who actually ran a query.

What privileges does the default postgres user have in Cloud SQL?

The default postgres user belongs to cloudsqlsuperuser and can log in, create roles, and create databases. Still, it does not hold true superuser or replication attributes, and requires a password before login.

The query runs. The emails stay hidden.