The Simplest Way to Make Ec2 Instances and Firestore Work Like They Should
Running ec2 instances and firestore together lets AWS compute apps read and write Google Cloud documents. Teams use workload identity federation so servers log in without static key files. Many companies run backend apps on AWS while keeping live document data in Google Cloud. Getting these two platforms to talk safely takes careful planning. You must link two different identity systems across the public network. When you set this up right, your apps read and write records fast. How ec2 insta
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 ec2 instances and firestore together lets AWS compute apps read and write Google Cloud documents. Teams use workload identity federation so servers log in without static key files.
Many companies run backend apps on AWS while keeping live document data in Google Cloud. Getting these two platforms to talk safely takes careful planning. You must link two different identity systems across the public network. When you set this up right, your apps read and write records fast.
How ec2 instances and firestore share identity and data
Each cloud uses its own system to check who is asking for data. An AWS server starts with an instance profile role attached to the machine. Google Cloud does not trust that AWS role on its own. You bridge this gap with workload identity federation in Google Cloud.
First, you create an identity pool in your Google Cloud project. You tell this pool to trust your specific AWS account ID. Next, the app on the server asks AWS for a temporary token. The app sends this AWS token to the Google security token service.
Google checks the token and gives back a short-lived Google token. The client library then uses this token to read or write document records. Data flows over encrypted web connections between the server and the database API. No static JSON key file ever sits on the hard drive.
Common failure modes and how to scope roles
The biggest mistake teams make is downloading a service account JSON key. Engineers copy this file onto several servers to make things work fast. If an attacker steals that file, they get full access from anywhere. These keys do not expire unless someone deletes them by hand.
Another common error is granting broad project owner roles to the database account. One bad query or compromised app can wipe out every collection in production. Shared accounts also ruin your audit logs when multiple apps use one identity. You cannot tell which server changed a sensitive user record.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
To fix this, give each AWS app its own distinct instance role. Map each AWS role to a matching Google service account with minimal rights. Scope those database permissions down to the exact collections the app needs. If a worker only reads data, never give it write access.
You must also watch how engineers run manual fixes from those servers. Developers often log in to a server to run one-off database scripts. If the server holds broad rights, any logged-in user inherits those same rights. Keep human maintenance access separate from automated machine roles.
Keeping network paths and audit logs clean
Traffic between AWS and Google Cloud usually travels over the public internet. Even though traffic uses TLS encryption, you still need tight network rules. Set up outbound firewall rules on your AWS security groups. Only allow traffic to leave on standard web ports toward Google IP ranges.
For stricter setups, teams link their cloud networks using private VPN tunnels. You can then route database traffic through private Google access endpoints. This keeps your document reads and writes off the public internet completely.
Turn on data access audit logs in your Google Cloud project right away. By default, Google logs admin changes but skips regular document reads and writes. Turning on data logs shows you which role touched which document and when. When you need to mask sensitive fields like emails, phone numbers, card numbers, or national IDs, masking rewrites matched fields in results.
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
Do I need a static JSON key file on my AWS server?
No, you should avoid static key files in production. Use Google Cloud workload identity federation to trade AWS role tokens for short-lived Google tokens.
How do I limit which collections an AWS server can read?
Assign a dedicated Google service account to your federated AWS role. Use IAM conditions and database security rules to restrict access to specific document paths.
Can I connect AWS servers to Google Cloud over a private network?
Yes, you can set up a site-to-site VPN or dedicated interconnect between both clouds. Then route your database traffic through Private Google Access IP ranges.
Related guides
In this post