When it comes to production databases, balancing access and security is key. Occasionally, we need to grant short-term database access for debugging a recent deploy or resolving a customer issue.
Yet, unchecked access is a security risk. This post will detail how to start granting temporary database access to Google Cloud SQL.
Granting access to your database on Google Cloud isn't a casual decision. While it might seem easier to give indefinite access, there are compelling reasons to opt for temporary permissions:
In essence, temporary database access isn't just a best practice or something to do for compliance—it's a necessity in maintaining a secure and efficient Google Cloud environment.
Before, we get into how to set up temporary access, let's look at the different ways of accessing Google Cloud SQL databases.
In order to get access to a Google Cloud SQL, there has to be a database user and a network connection to the database.
The database user is the account that is used to connect to the database. The network connection is the path that the human user takes to connect to the database.
Access Method | Pros | Cons | Best for Teams |
---|---|---|---|
Database User Per Human | - Easy auditing with per-user accounts - Fine-grained control per user | - Management overhead - Integration complexity | Under 10 engineers |
Bastion Host/Jumpbox with VPN Tailscale, Twingate, Boundary | - Additional security layer - Centralized traffic management | - Single point of failure - Increased latency | Under 50 engineers |
Identity-Aware Database Proxy StrongDM, Teleport | - Granular real-time oversight - Direct database integration | - Higher costs - Integration complexity | Over 50+ engineers |
When rendered, this table will neatly present the information for each access method alongside the team size it's most suitable for. Adjustments can be made based on specific organizational nuances and preferences.
This approach is the most straightforward, but can be cumbersome to manage as your team grows. When a user joins, they get a unique user name and will need to be added to the instance:
gcloud sql users create $USER_NAME \--instance=$INSTANCE_NAME \--password=$PASSWORD
Then you will need to grant database privileges on that user:
grant select on "$TABLE_NAME" to "$USER_NAME";
Think of this as a fortified gateway to your database. On this server (or container), you can record and monitor all database activity, and run a VPN to ensure secure connections.
Users can be managed directly from the networking layer and role-based access to the database through the monitored gateway.
Teams will often distinguish between read-only and read-write access, and set up isolated database users and gateways for each.
db-read
would grant access to read-only like SELECT
db-write
would grant access to INSERT
, UPDATE
, and DELETE
db-admin
would grant full admin access like GRANT
or DROP
Here are some examples of VPN solutions:
Once the users and gateways are set up, users can either SSH or connect directly via the networking solution to the database.
SELECT
without LIMIT
or any kind of destructive actions.Once your team grows to the point that managing individual database users is not feasible and role-based VPN-driven access doesn't have enough granularity of control, there are identity-aware proxy solutions designed for databases.
You can use your identity provider Okta, Microsoft Azure AD/Entra ID or Google Workspace as the identity provider and manage role-based access through identity groups.
Here are some database proxy solutions:
These solutions are designed to integrate directly with your database and provide a single point of entry for all users. They can be configured to provide granular access control, and can be integrated with your identity provider for seamless onboarding and offboarding.
Based on your organization's size, security requirements, and operational preferences, any of these solutions could be the right fit.
Once you've picked the preferred access pattern, you can start shifting users to temporary access in order to minimize risk and implement the principle of least privilege.
Indent is an access management platform that integrates with a myriad of services to allow on-demand access requests. It lets admins configure policies, and users can request temporary permissions which, upon approval, are provisioned automatically.
This can be a game-changer for organizations aiming to manage temporary database access dynamically and securely.
Here's how you can use Indent for each of the access patterns we discussed earlier:
/access
in Slack or indent.com/access on the web.Indent can help reduce the amount of standing production access to meaningfully improve security, without adding a ton of friction for engineers who need access urgently.
For some companies, it can resolve compliance requirements for certifications like SOC 2 Type II, ISO 27001, PCI DSS, or SOX.
We're happy to help you think through the right access patterns for your team and use case, feel free to reach out for a demo or contact us.
If you want to hear from a customer's experience with setting up Google Cloud SQL with Tailscale and Indent, check out this post from Stevan Arychuk (Head of SRE at Reclaim.ai) on the Tailscale blog.