Cloud Digital Leader Google Cloud Security Practice Question
A DevOps engineer needs to grant a CI/CD pipeline (running on Compute Engine) permissions to deploy a Cloud Run service. The pipeline uses a service account. What is the correct approach to assign the necessary IAM role to the service account?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Grant the Cloud Run Deployer role to the Compute Engine default service account
The best practice is to attach the service account to the Compute Engine instance and grant the Cloud Run Deployer role to that service account.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Create a new service account, grant the Cloud Run Deployer role, and export a key file to the instance
Why it's wrong here
Exporting a service account key file to the instance creates a long-lived credential that must be stored, rotated, and protected; if the instance is compromised, the key can be exfiltrated and used outside the instance. Attaching the service account directly to the instance via the metadata server avoids this risk, so while this option technically works, it violates the security best practice of avoiding service account keys in favor of instance-attached identities.
- ✓
Grant the Cloud Run Deployer role to the Compute Engine default service account
Why this is correct
The Compute Engine default service account is automatically attached to the instance and is authenticated through the instance metadata server, so no key file is needed. Granting it the roles/run.deployer role gives the pipeline permission to create and update Cloud Run services that run in the same project, while adhering to the principle of least privilege and avoiding long-lived credentials. This is the recommended pattern for workloads running on Compute Engine that need to deploy Cloud Run resources.
- ✗
Use the Cloud Run service agent with the roles/run.serviceAgent role
Why it's wrong here
The Cloud Run service agent (with roles/run.serviceAgent) is a Google-managed identity used by the Cloud Run control plane to perform operations like reading container images or writing logs; it is not an identity that a CI/CD pipeline should assume. The pipeline runs with its own service account, and using the service agent would grant internal service permissions that are neither intended nor appropriate for external deployments, and it would not provide the deployer role needed for the pipeline's actions.
- ✗
Grant the Cloud Run Admin role to the user account running the pipeline
Why it's wrong here
The pipeline runs as a service account, not as an individual user, so granting roles/run.admin to a user account does not affect the pipeline's permissions. Moreover, Cloud Run Admin is a broad role that allows creating, deleting, and updating all Cloud Run resources, which violates least privilege when compared to the more focused roles/run.deployer. The correct approach is to grant the deployer role to the service account identity that the pipeline actually uses, not to a human user's account.
Go deeper
Related to this question
Learn chapter
Cloud Digital Transformation
Key term
Compute Engine
Compute Engine is Google Cloud's Infrastructure-as-a-Service (IaaS) offering that lets you create and run virtual machines on Google's infrastructure.
Key term
Service
A service is a software component or system that performs a specific function and is available to be used by other programs or users over a network.
About these practice questions
This GCDL question is part of Courseiva's 829-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This GCDL practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the GCDL exam.