A enterprise team is configuring an automated CI/CD pipeline on Google Cloud using Cloud Build and Cloud Deploy to automatically build container images and deliver service updates to Cloud Run. To satisfy corporate compliance mandates, the Cloud Build execution service account must be configured according to the principle of least privilege so that it can create releases in Cloud Deploy and act on behalf of the deployment service account without gaining unnecessary administrative rights. Which IAM permission configuration meets these security and pipeline requirements?
- Grant the Cloud Build service account the Cloud Deploy Releaser role (roles/clouddeploy.releaser) at the project level, and grant it the Service Account User role (roles/iam.serviceAccountUser) specifically on the dedicated Cloud Deploy execution service account.Answer
- BGrant the Cloud Build service account the primitive Owner role (roles/owner) at the GCP project level to ensure it has all required permissions to build images, manage Cloud Deploy releases, and update Cloud Run revisions.
- CGrant the Cloud Build service account the Service Account Admin role (roles/iam.serviceAccountAdmin) at the project level so it can manage service accounts and execute deployment operations.
- DConfigure Cloud Build to save build artifacts and pipeline state files directly in unversioned local directory storage on the build worker instance to optimize execution speed.
Answer
Grant the Cloud Build service account the Cloud Deploy Releaser role (roles/clouddeploy.releaser) at the project level, and grant it the Service Account User role (roles/iam.serviceAccountUser) specifically on the dedicated Cloud Deploy execution service account.
The correct solution enforces the principle of least privilege. Granting the predefined Cloud Deploy Releaser role allows Cloud Build to create pipeline releases. Scoping the Service Account User role specifically to the target execution service account ensures that Cloud Build can pass that identity to Cloud Deploy without gaining access to other service accounts or administrative control.
Step-by-Step Solution
Key Concept
Least Privilege IAM Role Binding in Cloud Build and Cloud Deploy Pipelines