Infrastructure as Code on Google Cloud: Terraform, Infrastructure Manager, Config Controller and Cloud Foundation Blueprints

Google Cloud Platform Architect 55 min min read Updated: Nov 17, 2026 Intermediate
Infrastructure as Code on Google Cloud: Terraform, Infrastructure Manager, Config Controller and Cloud Foundation Blueprints
Intermediate Topic 3 of 3

Why Infrastructure as Code?

  • Manual clicking is slow, hard to repeat and hard to review
  • Code in Git gives review, history, rollback and repeatability
  • Same code can build dev, test and prod with different variables
  • Google recommends Terraform as the primary IaC tool. Deployment Manager is being phased out, so plan to move off it

Terraform Basics

ConceptMeaning
ProviderPlugin that talks to an API (hashicorp/google)
ResourceA thing to create (a bucket, a VM)
Variable / OutputInputs and results
StateTerraform's record of what exists. Keep it in a remote backend (Cloud Storage bucket with versioning)
ModuleReusable package of resources
Plan / ApplyPreview changes, then make them
hcl terraform { required_providers { google = { source = "hashicorp/google", version = "~> 6.0" } } backend "gcs" { bucket = "acme-tf-state" prefix = "shop/prod" } } provider "google" { project = var.project_id region = var.region } variable "project_id" { type = string } variable "region" { type = string default = "asia-south1" } resource "google_storage_bucket" "reports" { name = "${var.project_id}-reports" location = var.region uniform_bucket_level_access = true public_access_prevention = "enforced" versioning { enabled = true } } resource "google_service_account" "app" { account_id = "report-app" } resource "google_storage_bucket_iam_member" "app_read" { bucket = google_storage_bucket.reports.name role = "roles/storage.objectViewer" member = "serviceAccount:${google_service_account.app.email}" } output "bucket_url" { value = google_storage_bucket.reports.url }
bash terraform init terraform fmt && terraform validate terraform plan -var="project_id=my-proj" -out=tfplan terraform apply tfplan terraform destroy -var="project_id=my-proj"

Good Terraform Practices

  1. Use a remote state bucket with versioning and tight IAM. Never commit state files
  2. Never put secrets in code or state. Reference Secret Manager
  3. Use modules and a layout such as modules/, envs/dev, envs/prod
  4. Pin provider versions
  5. Run plan in pull requests and require review before apply
  6. Use service account impersonation or Workload Identity Federation in pipelines, not key files
  7. Tag resources with labels

Google's Managed Options

ToolWhat it is
Infrastructure ManagerGoogle-managed service that runs Terraform for you with deployments, revisions and previews
Config ConnectorCreate Google Cloud resources with Kubernetes YAML (declarative, for GitOps teams)
Cloud Foundation Toolkit / Terraform blueprintsReady, tested modules for landing zones, networks, projects and security
Service Catalog / Application Design CenterApproved templates for developers
Cloud Build / GitHub ActionsPipelines that run plan and apply

Landing Zone as Code

  • Define organization policies, folders, projects, Shared VPC, logging sinks and IAM in Terraform
  • Separate foundation (rarely changes, strict approval) from application stacks (teams change often)
  • Use drift detection: run terraform plan on a schedule to find manual changes

A Simple Pipeline

text Pull request ─► fmt + validate + security scan (Checkov / tfsec) ─► terraform plan (posted as comment) Merge to main ─► approval ─► terraform apply in Cloud Build ─► outputs and notifications

Practice

  1. Create the sample bucket and service account with Terraform
  2. Move the state to a Cloud Storage backend
  3. Wrap the bucket in a module and use it twice
  4. Run terraform plan after changing a label by hand and see the drift

Conclusion

Use Terraform (or Infrastructure Manager) to describe Google Cloud in code. Keep remote state, use modules, review plans in pull requests, authenticate with impersonation, and build landing zones from blueprints.

Quick Summary: why; Terraform; example; practices; managed options; landing zone; pipeline.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators