An enterprise architecture team is implementing an automated Infrastructure as Code (IaC) pipeline using Cloud Build and Terraform to provision Google Cloud environments across multiple projects. The pipeline must securely handle state management, prevent state file corruption during concurrent executions, and enforce the principle of least privilege for automated deployments. Which TWO actions should the team implement to satisfy these requirements?
- Configure a Google Cloud Storage bucket backend for Terraform state with Object Versioning enabled to support native state locking and state restoration.Answer
- Grant the Cloud Build service account specific predefined roles required for the target resources, along with the Service Account User role (roles/iam.serviceAccountUser) on designated runtime service accounts.Answer
- CStore the Terraform state (.tfstate) files directly in the Git repository alongside configuration files to track state history and prevent concurrency conflicts.
- DGrant the Cloud Build service account the Service Account Admin role (roles/iam.serviceAccountAdmin) to ensure it can manage and assign service account credentials across all workload projects.
- EAssign the primitive Owner role (roles/owner) to the Cloud Build service account at the folder level to prevent permission errors during environment provisioning.
Answer
Configure a Cloud Storage bucket backend with Object Versioning for state locking, and grant the Cloud Build service account specific predefined resource roles with roles/iam.serviceAccountUser on target service accounts.
Centralizing Terraform state storage in Google Cloud Storage with versioning ensures state consistency, encryption, and locking mechanism support across concurrent Cloud Build runs. Furthermore, restricting the Cloud Build service account to fine-grained predefined roles and granting roles/iam.serviceAccountUser specifically on required service accounts enforces least privilege while enabling successful compute resource attachment.
Step-by-Step Solution
Key Concept
Terraform remote state management with GCS and least-privilege IAM configuration for CI/CD automation pipelines.
Estimated Time:2m 0s