Fix GCP IAM Policy Inherit Errors
When working with GCP IAM, you may encounter a configuration error that prevents your deployment from working. This guide explains the most common mistake with policy inherit and shows the exact fix.
A Common Mistake
Assuming that project-level IAM bindings do not apply to resources in sub-folders, causing unexpected access denials or unexpected access grants through policy inheritance.
The incorrect command:
gcloud projects add-iam-policy-binding my-project --member=user:dev@example.com --role=roles/storage.admin
Error output:
The developer does not realize that this binding also grants access to resources in all folders under the organization node that contain this project. When the org restructures, moving the project to a different folder, the user retains admin access to storage through the project-level binding even if folder-level policies change.
The Correct Approach
The right way to configure policy inherit in GCP IAM:
gsutil iam ch user:dev@example.com:roles/storage.admin gs://specific-bucket
Successful result:
Updated IAM on bucket specific-bucket.
The user has admin access only on that specific bucket. Moving the project between folders does not affect this binding. The inheritance chain (org -> folder -> project -> resource) is bypassed by using resource-level binding.
How to Prevent This
Understand GCP's hierarchical IAM inheritance: org > folders > project > resource. Policies at higher levels flow down but can be overridden with resource-level policies. Use org-level policies for baseline security, folder-level for team isolation, project-level for environment defaults, and resource-level for exceptions. Audit with gcloud policies get-iam-policy at each hierarchy level.
FAQ
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Secure your cloud with DodaTech.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro