Configuring access · Topic 7 of 7

Resource Hierarchy and Organization Policies

Design the Google Cloud resource hierarchy, manage folders and projects at scale, and apply predefined and custom organization policies safely.

  • 5 min
  • Includes a diagram
In a nutshell
  • Organization, folders (up to 10 levels), projects, resources; policies flow down.
  • Effective IAM is the union of all ancestors; only deny policies subtract.
  • Organization policies restrict configurations regardless of IAM, mostly for new actions.

What it is

The resource hierarchy is the tree of organization, folders, projects and resources. Both IAM allow policies and organization policies are attached to nodes in this tree and flow down to everything below.

A good hierarchy lets you secure hundreds of projects with a few policies set on folders, instead of configuring each project.

Organizationdomain wide guardrailsFoldersenvironment or business unitProjectsone workload and environmentResourcesbuckets, VMs, datasets

How it works

Designing folders and projects

LayerTypical design
OrganizationOrg-wide policies, security team viewing roles, aggregated log sink
FoldersEnvironments (prod, nonprod) or business units, then environments; folders can nest up to 10 levels
ProjectsOne application and one environment per project; the trust and billing boundary
Shared projectsSeparate projects for logging, security tooling, Shared VPC hosts and KMS keys

Manage this at scale with infrastructure as code, for example Terraform modules that create projects with standard labels, budgets, APIs and IAM. Cloud Asset Inventory searches and exports every resource and policy across the organization.

Inheritance of IAM

The effective allow policy on a resource is the union of its own policy and every ancestor's. A grant on a folder applies to every project in it, and a child cannot remove a parent's grant.

WantDo
Same access to all prod projectsGrant once on the prod folder
Access to one project onlyGrant on that project
Remove inherited access for a subtreeDeny policy on that node, or move the grant lower
Different rules for some projects in a folderUse resource tags and conditional policies

Moving a project to another folder changes its inherited policies at once, so check what it gains and loses first.

Organization policies

Organization policies set what configurations are allowed, whatever IAM permits. Each policy sets a constraint on a node.

ConstraintEffect
iam.allowedPolicyMemberDomainsDomain restricted sharing: only identities from your Cloud Identity customer IDs can be granted roles
gcp.resourceLocationsResources only in allowed regions, for example in:eu-locations
compute.vmExternalIpAccessOnly listed VMs may have external IPs
compute.requireOsLoginSSH access through OS Login
storage.publicAccessPreventionNo public buckets or objects
iam.disableServiceAccountKeyCreationNo new service account keys
compute.skipDefaultNetworkCreationNew projects get no default network
name: folders/123456789/policies/gcp.resourceLocations
spec:
  rules:
  - values:
      allowedValues:
      - in:eu-locations
gcloud org-policies set-policy eu-only.yaml

Inheritance of organization policies

Organization policy inheritance: an organization rule restricting resource locations to the EU is inherited by a Production folder and its projects, while an Organization Policy Administrator replaces the rule on a Sandbox folder, whose projects use the folder rule. By default a node inherits its parent's policy. A child can replace it, or for list constraints merge with it, if the person has the Organization Policy Administrator role. Changes apply to new actions; most constraints do not alter resources that already exist.

Roll out safely with dry run policies, which log what would be denied without blocking. Tags plus conditional organization policies let one folder hold projects with different rules.

Custom organization policies

When no predefined constraint fits, write a custom constraint with a CEL condition on fields of a supported resource type.

name: organizations/123456789/customConstraints/custom.disableGkeAutoUpgrade
resourceTypes:
- container.googleapis.com/NodePool
methodTypes:
- CREATE
- UPDATE
condition: "resource.management.autoUpgrade == false"
actionType: DENY
displayName: Block GKE node pools without auto upgrade
gcloud org-policies set-custom-constraint custom-gke.yaml

After creating the constraint, enforce it with a normal policy on the organization, a folder or a project. Custom constraints are preventive: they block the non-compliant create or update request.

A worked example

A company is moving 200 projects to Google Cloud under strict EU residency rules. The engineer creates prod and nonprod folders under a business unit folder, and sets gcp.resourceLocations to in:eu-locations, domain restricted sharing and key creation blocking at the organization.

A dry-run custom constraint on the prod folder blocking GKE node pools without auto upgrade logs violations for two weeks before enforcement. Projects are created by a Terraform pipeline, so every new project inherits all of it.

Organizationlocations, domains, no keysProd foldercustom GKE constraintProject factoryTerraformNew projectsinherit policies

How the exam asks about this

  • "Ensure no IAM role can ever be granted to a Gmail account or another company's users." Domain restricted sharing with iam.allowedPolicyMemberDomains.
  • "All resources in the analytics folder must stay in Europe." gcp.resourceLocations set on that folder.
  • "Block GKE node pools that have auto upgrade turned off, and no predefined constraint exists." A custom organization policy constraint, tested in dry run first.

What to remember for the exam

  • Organization, folders (up to 10 levels), projects, resources; policies flow down.
  • Effective IAM is the union of all ancestors; only deny policies subtract.
  • Organization policies restrict configurations regardless of IAM, mostly for new actions.
  • Custom constraints use CEL on resource fields and are enforced with a normal policy.
  • Use dry run and the organization policy simulator before enforcing at scale.
Watch out

Domain restricted sharing also blocks grants to allUsers and allAuthenticatedUsers, and to partner identities whose customer ID is not listed. Test it in dry run before enforcing.

Common mistakes

Using IAM to stop a configuration. IAM controls who can act, not which settings are allowed. Region, external IP and key rules are organization policies.

Expecting an organization policy to fix existing resources. Most constraints only block new or updated resources. Find existing violations with Security Command Center or Cloud Asset Inventory.

Putting many environments in one project. A project is the main isolation boundary; mixing prod and dev in it makes least privilege impossible.

Check yourself

  • How does a folder IAM grant affect a project created in that folder next month?

    The project inherits it automatically, because effective policy is the union of all ancestor policies.

  • Which constraint keeps resources inside the EU?

    gcp.resourceLocations with an allowed value such as in:eu-locations.

  • What must you do after creating a custom organization policy constraint?

    Enforce it with an organization policy on the organization, a folder or a project, ideally in dry run first.

Topic 7 of 7 in Configuring access

Test yourself on Configuring access

The full Google Cloud Professional Cloud Security Engineer question bank has 749 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Google Cloud. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.