The Simplest Way to Make Cosmosdb and Fastly Compute Edge Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Running cosmosdb and fastly compute edge together lets teams serve global data with low delay. Edge workers handle user requests close to the browser and read records from the database. This setup speeds up web apps for users around the world. Yet it also creates new security risks for engineering teams. Edge code runs outside your main cloud network. Every database call crosses public networks and needs strict rules. How cosmosdb and fastly compute edge share data and roles Data flows betwe

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.

Running cosmosdb and fastly compute edge together lets teams serve global data with low delay. Edge workers handle user requests close to the browser and read records from the database.

This setup speeds up web apps for users around the world. Yet it also creates new security risks for engineering teams. Edge code runs outside your main cloud network. Every database call crosses public networks and needs strict rules.

How cosmosdb and fastly compute edge share data and roles

Data flows between these two systems over standard web requests. A user sends a request to the nearest edge server. The edge worker wakes up and checks the request details. When the worker needs stored data, it calls the database endpoint over HTTPS.

Edge apps cannot keep open database links across many requests. Each worker starts fast, does its job, and shuts down right away. Because of this, the edge code uses the database REST API. It sends an authorization header with every single call.

To log in, the edge worker needs a secret key or a token. Teams store this key inside the edge secret store. The worker reads the secret at runtime and signs the request. The database checks the signature and returns the matching JSON documents. Then the edge worker formats the reply and sends it to the user.

Common failure modes and how to scope roles

Many teams make mistakes when they first link these two tools. The biggest risk is putting a master database key in the edge store. A master key lets the holder read, change, or delete any table. If a developer leaks that key, an attacker can wipe out all data.

Shared service accounts cause another big problem for operations teams. When every edge worker uses the same key, logs look identical. You cannot tell which app or team ran a bad query. Engineers also run into trouble when they debug live issues. They often copy production keys to their laptops to test database queries. Those local keys stay on disks for months without any tracking.

CosmosDB RBAC + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

You can fix these risks by scoping roles down to the bare minimum. Never give an edge worker a full admin key. Create a read-only role if the edge app only fetches data. Scope the role to a single database container or partition key.

Next, set up a scheduled job to rotate your edge keys often. Short key lifetimes limit the damage if a secret ever leaks. You should also turn on diagnostic logs on the database side. Send every query log to a central place so your team can review them.

Managing human and service queries in production

Even with scoped edge keys, engineers still need to check production data. When an edge worker fails, someone has to inspect the raw records. Giving developers direct database keys breaks your security rules right away. A single typo in a manual query can delete thousands of user records.

Instead, teams should tie all human database sessions to their identity provider. Engineers should log in with their work accounts to run a quick check. You should also mask sensitive fields in query results. Masking rewrites card numbers, emails, and phone numbers before they reach the screen. This keeps private user data safe while teams fix bugs.

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

Edge workers use the HTTPS REST endpoint to read and write data. This avoids the slow setup of standard database drivers on each request.

How can we keep database keys safe at the edge?

Store read-only keys inside the encrypted edge secret store. Scope each key to specific data containers and rotate those secrets on a set schedule.

How do we stop engineers from sharing master keys during outages?

Remove static keys from developer laptops and require single sign-on for all database checks. Log every query by user identity and mask emails and phone numbers in results.

The query runs. The emails stay hidden.