The Simplest Way to Make Cloud Functions and Google Cloud Deployment Manager Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

You use cloud functions and google cloud deployment manager to run serverless code from templates. This pairing lets your team set up event-driven apps through repeatable files. Many teams build functions by hand in the web console at first. That manual habit breaks down when you run dozens of functions across staging and production. Putting both tools together gives you one clear source of truth for every function. How cloud functions and google cloud deployment manager share roles and data

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.

You use cloud functions and google cloud deployment manager to run serverless code from templates. This pairing lets your team set up event-driven apps through repeatable files.

Many teams build functions by hand in the web console at first. That manual habit breaks down when you run dozens of functions across staging and production. Putting both tools together gives you one clear source of truth for every function.

How cloud functions and google cloud deployment manager share roles and data

The template service reads your setup files and calls the function API for you. It packages your source code from a storage bucket and builds the runtime. Then it sets up the trigger that starts your function on each event.

Two distinct service accounts handle the work during and after the build step. The first account belongs to the deployment service and creates the cloud resources. This build account needs permission to read your code bucket and create functions.

The second account is the runtime identity that the function uses while it runs. Your template must assign this runtime account to the function during the build. So, the deployment account needs permission to attach that runtime identity to the new function.

Data flows from the event source into the function and then to other services. The template sets up the event source, such as a message topic or bucket. When a file lands in the bucket, the trigger sends the event data in. The function reads that data and uses its runtime role to write to databases.

Common failure modes and how to scope roles and network paths

A common mistake is using one broad service account for every single function. Teams often grant the default account full editor rights across the whole cloud project. If one function has a bug, an attacker can reach every table and bucket.

Cloud Functions IAM + GCP Access Context Manager: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Another failure mode happens when teams give the deployment service too much power. If the build account holds project owner rights, any template change can delete core databases. Shared accounts also make audit logs very hard for your security team to read. You cannot tell which function ran an unlogged query against a sensitive data table.

You can fix this by creating one small service account for each function. Set up that account inside the same template that builds the function itself. Grant it only the exact read or write role it needs for its job.

Next, lock down the network paths between your function and your backend data stores. Do not let functions reach databases over the public internet with open firewall rules. Route the function traffic through a private virtual network connector inside your cloud project.

You should also restrict who can trigger the function from the outside world. Set the ingress rule so only internal services or signed requests can start a run. Finally, turn on audit logs for both the deployment API and the data tables. Clean logs show you who changed a template and which function read a record. If your function returns personal records, mask emails and phone numbers in the output. Masking rewrites matched fields in results before they reach logs or external apps.

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

Why does my deployment fail with a permission error on the service account?

The deployment service account needs permission to act as the function runtime service account. Grant the service account user role to the deployment account on that runtime identity.

Where should I store the source code for the function template?

Store your zipped source code inside a dedicated cloud storage bucket with version history turned on. Point your template to that exact object version so every run uses known code.

How do I pass database secrets to a function without putting them in templates?

Never write plain text passwords or API keys inside your deployment template files. Store secrets in a dedicated secret manager and grant the function runtime account read rights.

The query runs. The emails stay hidden.