A digital banking enterprise is designing an automated infrastructure deployment pipeline using Cloud Build and Terraform across multiple Google Cloud projects. The architecture team requires that the pipeline prevents configuration state loss and adheres to strict least-privilege security principles during execution. Which architecture design approach should the team implement?
- Configure Cloud Build to store Terraform state in a Cloud Storage backend with object versioning enabled, and grant the build worker service account the Service Account User role to impersonate a dedicated deployment service account.Answer
- BAssign the primitive Editor role to the default Cloud Build service account across all target projects to ensure unrestricted access for executing Terraform resource provisioning.
- CGrant the Cloud Build service account the Service Account Admin role so the pipeline can dynamically create and manage specialized runtime service accounts for each build step.
- DStore the Terraform state file in local ephemeral storage within the Cloud Build workspace directory between build steps to minimize remote API calls during plan and apply execution.
Answer
Configure Cloud Build to store Terraform state in a Cloud Storage backend with object versioning enabled, and grant the build worker service account the Service Account User role to impersonate a dedicated deployment service account.
Storing state in a central Cloud Storage bucket with object versioning provides state locking, persistence, and recovery capability. Delegating execution by granting the `roles/iam.serviceAccountUser` role enables service account impersonation of a dedicated, fine-grained deployment service account, ensuring adherence to the principle of least privilege.
Step-by-Step Solution
Key Concept
Secure CI/CD Pipeline Architecture for Infrastructure as Code
Estimated Time:1m 30s