Designing versioned, auditable IaC on a serverless Google Cloud runtime
Short answer
A Keep application and Terraform module sources in Git, apply the infrastructure from Cloud Build, and deploy the workload to a Cloud Function so every change stays versioned, auditable, Google-managed and serverless.
Question
Key Takeaways
Versioned, auditable infrastructure as code on a serverless Google Cloud runtime works by keeping Terraform modules and application sources in one Git repository, applying them through Cloud Build, and deploying to Cloud Functions. Option A wins because it is the only design where declarative Terraform state, a Google-operated CI service and a genuinely serverless runtime all hold simultaneously. Cloud Run in option D is serverless, but its gcloud provisioning step leaves no plan or state file to audit.
Expert Analysis
Versioned, auditable infrastructure change combined with a Google-operated toolchain and a serverless runtime is satisfied only by keeping Terraform modules in Git, applying them from Cloud Build, and deploying to a Cloud Function, which is why option A survives all three filters.
Cloud Run stops short once gcloud commands replace declarative Terraform state
Option D is one step substitution away from being viable. It already pairs Cloud Build — a fully Google-operated CI service — with Cloud Run, a serverless container runtime that scales to zero and requires no node management, so two of the three stated constraints are met. If its first step instead read "apply versioned Terraform modules from the repository," D would satisfy versioning, auditability, Google-managed tooling and serverless execution at once, and the decision would collapse into a container-versus-function preference. That substitution is precisely what is absent. A sequence of gcloud invocations is imperative: it records the API calls that were issued, not the desired end state, so there is no plan to review before execution, no state file to detect drift afterwards, and no way to reconstruct what the infrastructure should look like when the pipeline is re-run against an environment someone edited by hand. The only artifact left in Git is script text, and a script is a procedure rather than a declaration of intent — reading its diff tells a reviewer which commands will fire, never which resources will change. Without a state backend the audit trail ends at "a command ran" and never reaches "this resource was created, updated, or left untouched."
Git-tracked Terraform applied by Cloud Build satisfies all three design requirements
Three constraints converge here: every infrastructure change must be versioned and auditable, the toolchain must lean on Google-managed services, and the workload must run on serverless compute. Option A meets all three without trading one for another. Application code and the Terraform modules describing the infrastructure sit in the same Git repository, so each change carries an author, timestamp and reviewable diff — that shared repository is what makes "versioned and auditable" true of infrastructure and not merely of the application. Terraform is declarative and stateful, so a plan articulates the delta between recorded state and declared configuration before anything is applied, and resources that exist but are absent from configuration surface instead of being silently orphaned. Cloud Build executes the apply as a Google-operated service, so no Jenkins controller or build VM has to be patched, scaled or backed up. The target runtime is a Cloud Function, serverless in the strict sense — no container, no cluster, no instance for the team to size or secure. Deployment Manager in option C and the gcloud calls in option D are also Google-hosted paths, yet neither closes the versioning-and-audit loop the way versioned modules plus remote state do.
Jenkins, Deployment Manager's Compute Engine target and ad-hoc gcloud scripts each break a requirement
Option B fails the Google-managed constraint outright: Jenkins from Cloud Marketplace is a third-party controller that lands on a Compute Engine VM, so the team inherits OS patching, plugin upgrades, credential stores and backups for the very component orchestrating deployments — and no step defines infrastructure as code at all, leaving the versioned-and-auditable requirement unmet. Option C gets orchestration right, running Cloud Build with Deployment Manager templates, but ends by placing a container on a Compute Engine instance, so the workload is neither serverless nor free of node management, and that instance's OS and firewall become the team's problem; its image-build step also produces a container nothing serverless consumes. Option D uses Cloud Run, genuinely serverless and Google-managed, plus Cloud Build, the correct pipeline engine — but infrastructure is created by gcloud invocations carrying no state, no plan and no declarative record of desired configuration, so the first requirement fails even though the last two pass cleanly. Option A is the sole arrangement where versioned Terraform modules, the Google-operated build service and the serverless runtime coexist.
Where the Cloud Build Terraform apply step converts a commit into a locked, auditable change
The decisive moment is the Cloud Build step that initialises the Terraform working directory against a remote backend and then runs plan followed by apply — not the Git push, and not the function deployment. Configure that backend as a Cloud Storage bucket: this single setting converts Terraform from a local convenience into a team-safe control plane, because the state object becomes the shared source of truth, generation-based locking prevents two concurrent builds from applying conflicting plans, and stored state makes drift visible when configuration and reality diverge. Emitting the plan as a build artifact, and failing the build when the plan is non-empty without approval, hands reviewers a machine-generated prediction of the change set. Cloud Build also stamps each build against its triggering commit, so the chain from commit hash to plan to applied result is reconstructable long afterwards — the practical meaning of auditable infrastructure. Terraform then reconciles resources rather than replaying commands, so a re-run after partial failure converges on declared state instead of duplicating resources. The Cloud Function deployment step is comparatively trivial; it consumes the same repository and inherits the same trail.
Official Reference
- https://developer.hashicorp.com/terraform/language/backend/gcs
- https://cloud.google.com/build/docs/overview
- https://cloud.google.com/functions/docs/concepts/overview
These links open the official vendor documentation in a new tab.
Exam Strategy
When an item lists several design requirements, score each option against every requirement in order and eliminate on the first unmet one rather than comparing overall elegance — here the Google-managed clause alone removes the Marketplace Jenkins deployment, and the serverless clause removes the Compute Engine target. Beware near-misses: a serverless runtime bolted onto imperative gcloud provisioning still fails an auditability requirement, so inspect the provisioning step, not just the deployment step. Writing the requirement list beside the options keeps the fastest disqualifier visible.
Related Analysis
Practice All PCD Questions
Access 84 questions with complete answers and detailed explanations.
View Full PCD Practice Test →