Overview and What You Will Learn
The GCP resource hierarchy is a four-level tree of Organization, Folders, Projects, and Resources, and policies set on a parent apply to everything beneath it. Every resource lives in exactly one Project, which is why the tree decides who can access what.
In this lab, you will:
- Create a Folder under your Organization
- Create a Project inside it with a deliberately chosen Project ID
- Grant a role once at the Folder level
- Inspect the inherited access correctly
Why This Matters in Production
A Project ID can never be changed after creation, while the display name can be edited freely. Imagine a platform team at a company like Grab creating test-proj-1 and planning to rename it before launch. Six months later production still runs under an ID that tells everyone it is a throwaway, and the only fix is a new project and a full migration. The hierarchy also decides who has access to what, so getting it right early saves a painful audit later.
Core Principles
Every GCP resource lives in exactly one Project, every Project sits in one Folder or directly under the Organization, and IAM allow policies set on a parent are inherited by all children. Inheritance is additive, so a child can add access but cannot remove an allow grant made higher up. Only an IAM deny policy can block inherited access.
devops.in] --> B[Folder
Engineering Team] B --> C[Project
checkout-service-prod-2026] C --> D[(VMs, buckets, databases)] classDef org fill:#475569,color:#FFFFFF classDef folder fill:#8B5CF6,color:#FFFFFF classDef project fill:#326CE5,color:#FFFFFF classDef res fill:#10B981,color:#FFFFFF class A org class B folder class C project class D res
A user's effective access is the combination of the policies at every level above the resource:
Each Project has three identifiers, and knowing the difference prevents mistakes:
- Project name is a display label that you can change at any time.
- Project ID is globally unique, chosen once, permanent, and cannot be reused even after the project is deleted.
- Project number is assigned by Google, is also permanent, and is used internally by many services.
Detailed Step-by-Step Practical Lab
How to Find Your Organization ID
The Organization node exists only when your account is tied to a Google Workspace or Cloud Identity domain. A personal Gmail account has no Organization, so the Folder steps below will not work for it. You also need permission to create Folders, such as the Folder Creator role.
gcloud organizations listexport ORG_ID=$(gcloud organizations list --format="value(ID)")How to Create a Folder
Capture the Folder ID in a variable so later commands do not need a pasted placeholder.
export FOLDER_ID=$(gcloud resource-manager folders create \ --display-name="Engineering Team" \ --organization=$ORG_ID \ --format="value(name.basename())") echo $FOLDER_IDHow to Create a Project Inside a Folder
Choose the Project ID as if it will run production forever, because it will. If the ID is already taken globally, add a suffix.
export PROJECT_ID="checkout-service-prod-2026" gcloud projects create $PROJECT_ID \ --name="Checkout Service Production" \ --folder=$FOLDER_IDHow to Check a Project's ID, Name, and Number
gcloud projects describe $PROJECT_ID \ --format="table(projectId, name, projectNumber)"How to Grant a Role at the Folder Level
A role granted on the Folder reaches every current and future Project inside it, so you grant once instead of per project.
gcloud resource-manager folders add-iam-policy-binding $FOLDER_ID \ --member="user:priya@devops.in" \ --role="roles/viewer"How to See Inherited IAM Permissions on a Project
This is where many engineers get misled. get-iam-policy shows only the bindings set directly on that one Project, so the Folder's Viewer grant will not appear there. Use the ancestors command to see the policy at every level.
gcloud projects get-iam-policy $PROJECT_ID # Policies on the Project and every ancestor: priya appears at the Folder levelgcloud projects get-ancestors-iam-policy $PROJECT_ID # The chain of parents from this Project up to the Organizationgcloud projects get-ancestors $PROJECT_IDCommon MistakeAuditing "who has access to this project" with
gcloud projects get-iam-policyalone. It omits everything inherited from Folders and the Organization, so you will under-report access. Useget-ancestors-iam-policy, or the Console IAM page, which labels inherited roles.
How to List the Projects Inside a Folder
gcloud projects list --filter="parent.id=$FOLDER_ID"How to Clean Up
gcloud projects delete $PROJECT_ID --quiet # A Folder must be empty before it can be deleted. If this fails because the# project is still in pending deletion, wait for it to clear or move the project outgcloud resource-manager folders delete $FOLDER_IDRememberA deleted project is not removed immediately. It enters a 30-day pending-deletion window, and its Project ID is never available for reuse.
Production Best Practices & Common Pitfalls
Common MistakePicking a placeholder Project ID like
test-123and planning to rename it later. The ID is permanent, so a project promoted to production needs a brand-new project and a full migration to get a proper ID.
TipMirror your real organization in Folders, by team, by environment, or both. Then apply IAM roles and Organization Policies once at the right level instead of repeating them across dozens of projects.
- Name Project IDs for their long-term role. A pattern like
service-environment-year(for examplecheckout-service-prod-2026) stays accurate and sortable. - A Project belongs to exactly one Folder, or directly to the Organization. If a project's access needs differ sharply from its Folder, it probably belongs in a different Folder, not under a pile of overrides.
- Grant roles to groups, not individuals, at Folder level. Group membership changes then update access everywhere without touching IAM policies.
- Audit every level of the tree. A role granted at the Organization or Folder is invisible if you only inspect the Project's own policy.
Quick Reference & Troubleshooting Commands
| Command | Description |
|---|---|
gcloud organizations list |
Find your Organization ID |
gcloud resource-manager folders create |
Create a new Folder |
gcloud projects create ID --folder=FOLDER_ID |
Create a Project with a permanent ID in a Folder |
gcloud projects get-iam-policy ID |
Show only bindings set directly on the Project |
gcloud projects get-ancestors-iam-policy ID |
Show policies at the Project and every ancestor |
gcloud projects list --filter="parent.id=FOLDER_ID" |
List Projects within a Folder |
gcloud projects describe ID --format="table(projectId,name,projectNumber)" |
Compare a Project's three identifiers |