An enterprise development team is setting up an automated CI/CD pipeline using a deployment service account to provision Compute Engine instances via Terraform. The deployed virtual machines need to run applications under a dedicated runtime service account. The team wants to allow the pipeline service account to attach this runtime service account to the virtual machines without granting excess administrative permissions. Which recommendation should you give to the development team?
- Grant the deployment service account the Service Account User role on the dedicated runtime service account.Answer
- BGrant the deployment service account the Service Account Admin role at the project level.
- CGrant the deployment service account the Project Editor primitive role.
- DStore the Terraform state files inside the temporary CI/CD runner local filesystem without persisting them to a Cloud Storage backend.
Answer
Grant the deployment service account the Service Account User role on the dedicated runtime service account.
Granting the Service Account User role (roles/iam.serviceAccountUser) on the specific target service account allows the deployment pipeline to attach that service account to new Compute Engine instances. This fulfills the deployment requirement while adhering strictly to the principle of least privilege.
Step-by-Step Solution
Key Concept
Least privilege service account attachment and IAM scoping