A global logistics enterprise manages its multi-tenant Google Cloud architecture using Terraform within Cloud Build continuous integration pipelines across separate development, staging, and production GCP organizations. The lead cloud architect must design an Infrastructure as Code (IaC) execution and security framework that satisfies four critical requirements:
1. CI/CD pipeline runners must authenticate without storing long-lived service account JSON keys in repositories or build secrets.
2. Terraform execution across environments must isolate state files to prevent concurrent state locks and accidental cross-environment modifications.
3. Automated pipeline service accounts must enforce least-privilege security scoping tailored to each environment.
4. Unsanctioned configuration changes made directly through the Cloud Console or gcloud CLI must be automatically detected and safely aligned with declared IaC configurations.
Which architecture meets all requirements while following Google Cloud recommended best practices?
- Authenticate Cloud Build using Workload Identity Federation to eliminate service account keys. Store state in distinct Cloud Storage buckets per environment configured with Object Versioning and state locking. Grant environment-specific fine-grained IAM roles to dedicated pipeline service accounts, and run scheduled automated terraform plan checks alongside Cloud Asset Inventory feeds to detect and reconcile configuration drift.Cevap
- BAuthenticate Cloud Build using Workload Identity Federation. Store all backend state files in a centralized Cloud Storage bucket with Object Versioning enabled. Assign the IAM Owner role to a single global CI/CD service account to streamline resource provisioning across all environments, and rely on manual weekly Cloud Shell audits to identify infrastructure drift.
- CGenerate JSON service account keys for each environment and store them as encrypted variables in Cloud Build. Persist Terraform state files locally inside the ephemeral storage of the Cloud Build container runner to avoid Cloud Storage API latency, and run terraform refresh before every build to overwrite manual infrastructure modifications.
- DAuthenticate Cloud Build runners using short-lived access tokens generated by a master service account. Store state in a single shared Cloud Storage bucket. When manual infrastructure drift occurs in production, edit the remote terraform.tfstate file directly in the bucket using a JSON editor to match the live infrastructure state.