Google Cloud Engineer interview question · Most asked
How do you run Terraform for Google Cloud safely in a team?
How you'd do it Asked in Cloud Engineer interviews
Summary
Store state in a Cloud Storage backend (with object versioning; the GCS backend locks state natively), run plans and applies from CI with a dedicated service account authenticated through Workload Identity Federation, pin provider versions, and review plans on pull requests. Split state by environment and component so one apply can't touch everything.
Longer Answer
terraform {
backend "gcs" {
bucket = "acme-tfstate-prod"
prefix = "network"
}
required_providers {
google = { source = "hashicorp/google", version = "~> 7.0" }
}
}
- The CI service account has only the roles needed for that stack; humans impersonate it for break-glass.
- Enable required APIs in Terraform (
google_project_service) and beware of disabling them on destroy. - Use
google_project_iam_member(additive) rather than_binding/_policyresources unless you intend to own the whole policy, which can remove others' access. - Drift: scheduled plans; Config Validator or policy checks on plans.
Key Points
- GCS backend with versioning and locking.
- CI with Workload Identity Federation, no keys.
- Pin providers; split state.
- Prefer additive IAM member resources.
- Scheduled plans for drift.
Explanation
What interviewers look for
Safe state handling and the IAM resource gotcha specific to the Google provider.
More Google Cloud Engineer questions
- How do you design a Google Cloud landing zone for a company with several teams?
- Explain Google Cloud's resource hierarchy: organisation, folders, projects and resources.
- How does IAM work in Google Cloud, and why should you avoid basic roles?
- When would you choose Cloud Run, GKE or Compute Engine?
- What are service accounts, and how should workloads authenticate without service account keys?
- Compare Google Cloud's database options: Cloud SQL, AlloyDB, Spanner, Firestore and Bigtable.
- How is networking in a Google Cloud VPC different from AWS?
- Design a highly available web application on Google Cloud.