The Simplest Way to Make Spanner and VS Code Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Engineers use spanner and vs code together to write, test, and run database queries in one editor. This setup lets teams check tables, edit schema files, and debug app data from their laptops. Google Cloud Spanner is a global relational database that handles massive read and write loads. Visual Studio Code is a fast code editor with extensions for cloud databases. When you join them, developers do not need to switch between the browser console and their code. They can read schema details and ru

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.

Engineers use spanner and vs code together to write, test, and run database queries in one editor. This setup lets teams check tables, edit schema files, and debug app data from their laptops.

Google Cloud Spanner is a global relational database that handles massive read and write loads. Visual Studio Code is a fast code editor with extensions for cloud databases. When you join them, developers do not need to switch between the browser console and their code. They can read schema details and run test queries right beside their app logic.

How spanner and vs code share identity and data

To make spanner and vs code talk, the editor needs valid Google Cloud credentials. Most developers log in through their local cloud tool to save a user token on disk. The database extension inside the editor reads this local token to prove who the user is. Once the token passes the check, the extension opens a secure network channel to the cloud project.

After login, the Cloud Identity and Access Management system checks the user role. That role decides which instances, databases, and tables show up in the editor sidebar. When a developer runs a query, the editor sends the statement to the Google Cloud API. The database runs the statement and sends the matching rows back to the local screen. If the developer lacks the right role, the cloud API blocks the request right away.

Common failure modes and how to scope roles

Many teams take shortcuts when they set up local database tools for their engineers. A common mistake is sharing one strong service account key across the whole development team. Developers download this static key file to their laptops and point their editor at it. If a laptop is lost or stolen, an attacker gets full database permissions right away. Also, shared keys ruin audit logs because every query looks like it came from the same robot account.

Broad user tokens are another big risk for production data. When a developer logs in with an admin role, a bad query in the editor can drop tables. Local editors also store query history and results in plain text on the local hard drive. If a query returns customer emails or card numbers, that sensitive data now sits on a laptop.

Infrastructure as Code Security Scanning + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, teams must stop using static service account keys on user laptops. Give each engineer a personal cloud identity tied to single sign-on. Scope default roles to read-only permissions so daily editor work cannot break live tables. Use local database emulators for schema changes and destructive tests instead of live cloud instances. Lock down network paths with private cloud perimeters so stolen tokens cannot work from outside networks.

Managing local schema changes and query safety

Writing schema changes in a local editor is fast, but running them live is risky. Large schema updates can lock resources or slow down live app traffic if done wrong. Teams should write and check their schema files in the editor, then push them to version control. Automated build pipelines should run those schema changes after a teammate checks the pull request.

For live data checks, keep local queries small and specific. Remind engineers to limit row counts when they test queries from their editor. Masking tools can also rewrite sensitive fields like phone numbers or national IDs in query results. This keeps real user records off developer laptops while still letting engineers debug app issues.

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 runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Can I test Spanner queries in VS Code without a live cloud instance?

Yes, you can run the local Spanner emulator on your laptop inside a container. Point your editor extension to the local emulator port to test schema changes and queries for free.

Why should teams avoid service account JSON keys for local editors?

Service account keys do not expire by default and are easy to leak on laptops. If two engineers use the same key file, cloud logs cannot show who ran a specific query.

How do I stop developers from changing live data from their code editor?

Grant developers a read-only database role in Google Cloud IAM for their daily accounts. Require a peer review process or a separate approval workflow before anyone runs write statements.

The query runs. The emails stay hidden.