An enterprise logistics company is analyzing its continuous integration and continuous delivery (CI/CD) pipelines used to manage Google Cloud infrastructure with Terraform and Cloud Build. During a pipeline security and operational analysis, the Cloud Architect identifies two significant vulnerabilities: concurrent pipeline executions corrupt local Terraform state files, and the Cloud Build service account has been granted primitive Project Editor privileges along with broad administrative rights over project service accounts. Which TWO actions should the architecture team implement to remediate these issues while adhering to Google Cloud best practices? (Select TWO)
- Migrate the Terraform state storage backend to a Cloud Storage bucket with object versioning and state locking enabled.Answer
- Replace primitive Editor roles on the Cloud Build service account with minimal predefined roles and grant 'roles/iam.serviceAccountUser' on specific deployment service accounts.Answer
- CStore Terraform state files on ephemeral local disk storage allocated to individual Cloud Build worker instances to bypass remote locking overhead.
- DGrant the primitive Owner role to the Cloud Build service account across all target environment projects to streamline resource deployment capabilities.
- EAssign the Service Account Admin role to the Cloud Build service account to allow dynamic service account creation during build executions.
Answer
The team must migrate the Terraform state storage backend to a Cloud Storage bucket with object versioning and state locking enabled, and replace primitive Editor roles on the Cloud Build service account with minimal predefined roles while granting 'roles/iam.serviceAccountUser' on specific target service accounts.
To fix state corruption and enforce operational stability, Terraform state must be stored in a centralized Cloud Storage bucket configured with versioning and state locking. To secure the pipeline according to GCP least privilege practices, primitive Editor roles must be removed from the build service account and replaced with minimal predefined roles, combined with 'roles/iam.serviceAccountUser' granted specifically on deployment identities.
Step-by-Step Solution
Key Concept
CI/CD Pipeline Security and Infrastructure as Code State Management