The Simplest Way to Make Cloud Run and Google Compute Engine Work Like They Should
Teams pair cloud run and google compute engine to split web traffic from heavy tasks. Cloud Run handles fast web requests while Compute Engine runs steady background jobs and databases. This split lets each tool do what it does best in production. Stateless containers scale down to zero when web traffic drops at night. Virtual machines stay on to run stateful apps, custom kernels, and long batch jobs. Together, they give your team a balanced setup for cost and speed. How cloud run and google
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 pair cloud run and google compute engine to split web traffic from heavy tasks. Cloud Run handles fast web requests while Compute Engine runs steady background jobs and databases.
This split lets each tool do what it does best in production. Stateless containers scale down to zero when web traffic drops at night. Virtual machines stay on to run stateful apps, custom kernels, and long batch jobs. Together, they give your team a balanced setup for cost and speed.
How cloud run and google compute engine share data and roles
Data moves between these two services over a private virtual network. A serverless VPC connector lets your containers send traffic straight to internal VM IP addresses. Packets stay inside the cloud network and never touch the public internet. This path keeps latency low and blocks outside attackers from seeing your traffic.
Each service uses its own identity to prove who it is. You assign a specific service account to your container revision. You also assign a separate service account to your virtual machine instance. IAM rules then check if the container role can talk to the VM.
When a container calls an internal API on a VM, it attaches an identity token. The app on the VM checks this token before it runs the request. If the VM needs to trigger a container, it sends a signed token back. You only grant the exact role needed for that single call.
Common failure modes and how to fix them
Many teams make the mistake of using the default compute service account everywhere. That default role often has broad editor permissions across the whole project. If an attacker breaks into one web container, they gain full control over your VMs. Stop using default accounts and build one custom account per app instead.
Another common risk comes from routing traffic over public IP addresses. Teams sometimes open firewall ports to the whole internet so containers can reach a VM. This setup exposes your backend services to port scans and brute force attacks. Route all traffic through an internal network connector and lock down your firewall rules.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Firewall tags help you control which machines can talk to each other. Put a target tag on the VM that runs your internal database or worker. Set a firewall rule that only allows traffic from the connector subnet. Block all other internal subnets from reaching that specific port on the VM.
Unlogged database queries and SSH sessions also create huge blind spots for security teams. When engineers or containers connect to a VM, standard network logs only show IP addresses. You cannot see which query ran or what sensitive data came back. Add query logging and use data masking to rewrite emails and card numbers in results.
Scoping network paths and runtime permissions
Good security starts with tight boundaries around each workload in your cloud project. Give every container service its own service account with zero broad project roles. Grant that account permission to invoke only the specific target it needs. Review these role bindings every month to clear out unused permissions.
Keep your virtual machines off the public internet whenever you can. Remove external IP addresses from backend VMs that only serve your internal containers. Use private network routing so containers reach VMs through internal addresses only. This simple change cuts off the main path that outside attackers use.
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
How does a Cloud Run service talk to a private Compute Engine VM?
You set up a serverless VPC access connector or direct VPC egress in your project. The container sends requests through this private path to the internal IP of the VM.
Should both tools share the same service account in production?
No, sharing one service account gives both tools the exact same permissions. Create a separate service account for each workload so you can limit access per app.
When should a workload move from a container to a virtual machine?
Move a workload to a VM when it needs local disk state or steady CPU. Keep stateless web APIs and short webhook jobs on containers that scale per request.
Related guides
In this post