Your team created a user-managed service account named [email protected]. The account must read objects from every Cloud Storage bucket in project log-proj. You want to grant the predefined Storage Object Viewer role to the service account at the project level without modifying any other existing IAM bindings. Which gcloud command accomplishes this goal?
gcloud projects set-iam-policy log-proj policy.yaml (with the new binding added manually to the file)
To grant a role to a principal for an entire project and keep all other bindings unchanged, you use gcloud projects add-iam-policy-binding. The command appends the new binding to the current project-level IAM policy instead of replacing it. Supplying the service account as the member and roles/storage.objectViewer as the role satisfies the requirement that the account can read objects across all buckets in the project.
Using gcloud iam service-accounts add-iam-policy-binding would attach a role on the service-account resource, not give that service account access to project resources. Setting the policy with gcloud projects set-iam-policy could work, but it risks overwriting the policy if you do not first merge existing bindings. Adding a binding on an individual bucket would not cover every bucket in the project.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the purpose of the Storage Object Viewer role in GCP?
Open an interactive chat with Bash
What is the difference between `gcloud projects add-iam-policy-binding` and `gcloud iam service-accounts add-iam-policy-binding`?
Open an interactive chat with Bash
Why does overwriting IAM policy using `gcloud projects set-iam-policy` carry risks?
Open an interactive chat with Bash
What is the purpose of IAM policy bindings in GCP?
Open an interactive chat with Bash
What does the `gcloud projects add-iam-policy-binding` command do?
Open an interactive chat with Bash
Why is it incorrect to use `gcloud iam service-accounts add-iam-policy-binding` in this scenario?
Open an interactive chat with Bash
GCP Associate Cloud Engineer
Configuring access and security
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .