You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Managing infrastructure as code on Google Cloud requires disciplined practices across organisation, security, state management, testing, and operations. This lesson consolidates best practices for Deployment Manager, Terraform, and the broader IaC workflow on GCP.
Organise your IaC code to match your environments and team structure:
infrastructure/
modules/
vpc/
gke-cluster/
cloud-run-service/
cloud-sql/
environments/
dev/
main.tf
variables.tf
terraform.tfvars
backend.tf
staging/
main.tf
variables.tf
terraform.tfvars
backend.tf
production/
main.tf
variables.tf
terraform.tfvars
backend.tf
| Resource Type | Convention | Example |
|---|---|---|
| Projects | {org}-{env}-{service} | acme-prod-payments |
| VPCs | {env}-{purpose}-vpc | prod-main-vpc |
| Subnets | {env}-{region}-{purpose} | prod-euw1-web |
| GKE clusters | {env}-{region}-{name} | prod-euw1-primary |
| Service accounts | {service}-{role}@ | payments-api@ |
| Buckets | {project}-{purpose} | acme-prod-terraform-state |
Apply labels consistently to all resources:
locals {
common_labels = {
environment = var.environment
team = var.team
managed_by = "terraform"
cost_centre = var.cost_centre
}
}
resource "google_compute_instance" "web" {
# ...
labels = local.common_labels
}
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.