Home› Blog› Week 10 — Group-Based Access Control in Google Clo…
GCP Weekly Lab GCP Terraform

Group-based access control in Google Cloud

Move a permission from a named identity onto a group, then prove that access appears and disappears with group membership alone.

Verified against current vendor documentation on 24 October 2026. Pricing, limits and API behaviour were checked against the official docs on that date. Cloud services change fast — if you are reading this much later, treat the specifics as a starting point and re-check the linked sources.
GCP Platform Engineering Lab · Week 10 of 58

Lab Overview

The problem. Someone joins the team and needs to read logs. Someone else changes role and should stop. If permissions are attached to named identities, each of those requests means editing the IAM policy that governs the whole organization — a heavy, high-blast-radius change for a small ask.

Objective. Move one role binding from an individual identity onto a Google group, then demonstrate that access follows group membership and nothing else — including how long the change takes to take effect.

Expected outcome. A folder-level role held by a group, a test identity whose only route to that permission is its membership, and a measured figure for how fast adding and removing membership changes real access.

DifficultyIntermediate — no new network or compute concepts, but it crosses two separate administrative systems
TimeApproximately 90 minutes, excluding propagation waits (estimate, not measured)
DeploymentTerraform via HCP Terraform remote execution, authenticated by Workload Identity Federation — no service account keys
Sourceweek-10-group-access
Cost$0 — measured, see Security and Cost
Reproduce itLab guide — exact commands, expected outputs, validation and cleanup

Cloud Services and Concepts

ServicePurpose hereWhat it is
Cloud Identity Holds the group that carries the permission Google's directory of people and groups for your domain. A separate product from IAM, with its own API and its own administrators, managed at admin.google.com.
Google Groups The group itself, used as an IAM principal An email address that contains members. IAM accepts a group address anywhere it accepts a user, and never asks who is inside.
Cloud IAM Grants roles/logging.viewer to the group at a folder The permission system: which identity may perform which action on which resource. A grant on a folder is inherited by every project inside it.
Resource Manager Supplies the folder the grant attaches to The resource hierarchy — organization, folders, projects — that IAM grants hang from.
Cloud Logging The resource being read, to prove access works Log storage and query. Used here only as a permission target: "can this identity read logs" is the question the lab answers.

The one idea to hold on to: Cloud Identity and IAM are two separate lists — who exists, and who may do what. They touch at exactly one point: IAM accepting a group address as a principal. They are administered through different consoles, by different roles.

Architecture and Workflow

The role belongs to the group GCP Lab · Week 10 Icon_24px_IAM_Color a service account holds no roles an access group holds logging.viewer on the platform folder platform folder contains the logging project Icon_24px_Logging_Color its logs readable — for now member of access appears and disappears with membership and nothing else jayanthkatta.com grp:470,170,360,150;folder:420,470,460,150

The flow

  1. Terraform, running on HCP Terraform, authenticates to Google Cloud through Workload Identity Federation — a short-lived token exchange, no stored key.
  2. It creates an access group in Cloud Identity. The group is parented to the directory (customers/<id>), not to the resource hierarchy.
  3. It creates a test service account with no role bindings of its own, and adds it to the group as a MEMBER.
  4. It grants roles/logging.viewer to the group on the platform folder. Every project in that folder inherits the grant.
  5. The test identity reads logs. Its only path to that permission is the membership.
  6. The membership is removed, access is re-tested, then the membership is restored — three times each way, timing both transitions.

Two decisions worth naming

The test subject holds no role of its own. A revocation test run as a principal that can reach the permission another way proves nothing, and the obvious human in this organization holds Organization Administrator.

Static membership, not dynamic groups. Membership from a query rather than a list requires Cloud Identity Premium; this is the free edition, so removal is an explicit act rather than a consequence of an attribute changing.

Prerequisites

  • Cloud Identity on a verified domain — the free edition is sufficient.
  • An organization with a folder containing a project. The grant is folder-scoped, so a bare project will not do.
  • Terraform 1.9+ with hashicorp/google ~> 6.0, and the Google Cloud SDK.
  • roles/resourcemanager.folderAdmin on the Terraform apply identity — not Organization Administrator.
  • Group Administrator, a Workspace admin role granted in the Admin console. It has no gcloud or Terraform equivalent, which makes it the one step a pipeline cannot bootstrap for itself.

Week 1's folder hierarchy is assumed. Week 2's keyless CI is not required — local Terraform reproduces the lab. Exact permissions, versions and variables are in the lab guide.

Implementation

Six resources, deployed in this order. Exact commands, variables and expected outputs are in the lab guide; what follows is why each piece exists.

First, the starting state. The directory held no groups at all before any of this ran, which is what makes the later membership test mean something: the group the subject joins is one this configuration created, not one it was already in.

The Admin console Groups list, empty, before anything in this lab was deployed.
The precondition, captured before the first apply: zero groups in the directory. This one cannot be retaken — the moment the apply creates a group, the empty list is gone for good.
Repository structure: LAB.md, terraform, scripts and docs, each with a one-line responsibility.
How the week is organised. Full source on GitHub.

Step 1 — Configure the provider for a client-based API

Why: Cloud Identity bills the caller's project, and a group belongs to no project at all. Without this the call is attributed to a Google-owned project and fails with SERVICE_DISABLED.

provider "google" {
  user_project_override = true
  billing_project       = var.seed_project_id
}

Validation: gcloud identity groups search --billing-project=<project> returns without a permission error.

Step 2 — Create a test identity that holds nothing

Why: a revocation test run as a principal that can reach the permission another way proves nothing. The obvious human here holds Organization Administrator, so removing a membership would change nothing for them. The subject is a service account with no role bindings, so group membership is its only route to the permission.

Validation: the organization IAM policy returns no bindings naming the account.

Step 3 — Create the access group

Why: the group is what the permission attaches to. It is parented to customers/<directory-id> — the directory, not the resource hierarchy. An organizations/ parent is rejected, making this the only resource in the lab that does not hang off the hierarchy.

Validation: gcloud identity groups describe <address> resolves it. groups search --organization=... will not — see Troubleshooting.

Step 4 — Add the member, then grant the role to the group

Why: MEMBER can use the access the group carries; MANAGER and OWNER could also change who else has it. The grant names the group address rather than a person, and sits on a folder rather than the organization because the pipeline's write identity deliberately lacks Organization Administrator.

resource "google_folder_iam_member" "log_readers_can_read" {
  folder = var.platform_folder_id
  role   = "roles/logging.viewer"
  member = "group:${google_cloud_identity_group.log_readers.group_key[0].id}"
}

_member and never _binding: the _binding form is authoritative for the whole role and would silently remove every other holder of it on that folder.

Validation: the folder's IAM policy lists a group: principal for the role.

Google Cloud IAM page for the platform folder. The Type column shows a group icon holding the Logs Viewer role.
Proves the architectural change: the principal holding Logs Viewer on this folder is a group, not a person. The address is redacted by the capture tooling, which publishes service identities only.

Validation and Evidence

Successful deployment is not successful validation. An apply creating six resources proves only that the API accepted them. What the lab claims is that access follows membership, and that needs a different test.

What was tested

TestExpectedActualStatus
Infrastructure deployed6 resources6 added, 0 changed, 0 destroyedPass
Role held by a group, not a persongroup: principal on the foldergroup:grp-gcp-log-readers@...Pass
Subject holds no direct rolezero bindingszero bindingsPass
Subject can read logs via membershipquery succeedsquery succeededPass
Access lost when membership removedquery denieddenied after 30 s / 20 s / 10 sPass
Access restored when membership restoredquery succeedssucceeded after 30 s / 30 s / 10 sPass
The plan identity's read-only role is what unblocked refreshrefresh fails without itnot tested — two changes were in flight at onceUnverified

Deploying successfully is not the same as the solution working. Row one is deployment. Rows five and six are what actually prove the lab's claim — that access follows membership. The last row is a control this run did not establish, recorded rather than quietly dropped.

Measurement output: membership removed and access gone after 30, 20 and 10 seconds; restored and access back after 30, 30 and 10 seconds.
The evidence behind rows five and six: the same command, by the same identity, succeeding and failing either side of a membership change. Three trials each direction, ten-second poll.

What the evidence proves, and what it does not

It proves the indirection works: an identity holding no role of its own gained and lost a real permission purely through group membership, and the change took effect within half a minute. It does not describe propagation when membership arrives from an external identity provider — Google documents that as taking up to several hours, and there is no external provider here, so that figure belongs to a different system.

validate.sh asserts the surrounding facts against the live organization rather than Terraform state: the group exists, the subject holds nothing directly, it is a MEMBER and not a manager, and the folder role is held by a group. It ran green end to end before teardown — which matters, because after a destroy it cannot be run again.

Security and Cost

Security decisions

ControlDecision and trade-off
Least privilege, GCP side The grant sits on a folder, not the organization, and the test identity holds nothing directly. Plan and apply run as separate identities.
Least privilege, directory side Accepted over-grant. The apply identity holds Group Administrator, which can administer every group in the directory, including ones it did not create. Cloud Identity documents no narrower path for a service account.
Credentials No service account keys. HCP Terraform authenticates by Workload Identity Federation; nothing long-lived is stored.
Network exposure None. No compute, no endpoints, no public surface.
Observability Group and membership changes land in Admin console audit logs, which are separate from Cloud Audit Logs — a monitoring gap worth knowing about.

One control here is unproven. The plan identity was given a custom Workspace role carrying one privilege, Groups → Read. The next apply succeeded — but the Group Administrator grant was still propagating at that moment, so this run cannot separate "the read-only role worked" from "the broader grant took effect". Two changes in flight at once is a testing mistake, not a finding.

For production, this configuration would additionally need: a naming convention plus an organization policy constraint preventing ad-hoc collaboration groups from being granted IAM roles; Cloud Identity security groups rather than plain groups, so access-bearing groups are distinguishable at audit time; and alerting on membership changes to access groups.

Cost

ItemCharge
Cloud Identity groups and memberships$0 — included in the free edition
IAM bindings, service accounts, API enablement$0 — never billed
Cloud Logging reads during testing$0 — within free tier
Measured total for this lab$0.00, read from the billing export rather than a rate card

Free-tier dependency worth naming: dynamic groups require Cloud Identity Premium. Designing around attribute-driven membership means a paid tier.

Troubleshooting and Lessons

A group the pipeline could not read

Problem: the apply reported the group created, then every subsequent run failed with 403 Permission denied for resource groups/….

Root cause: initial_group_config = "WITH_INITIAL_OWNER" — documented as making the caller the group's owner, and offered as the least-privilege alternative to a directory-wide admin role — created the group with zero members and no owner. Confirmed through both gcloud and the REST API.

Resolution: assign Group Administrator to the apply identity in the Admin console.

Lesson: an apply that reports success is not proof the resource is manageable. Read the object back as the identity that will have to maintain it.

A 403 that was really a clock

Problem: after granting Group Administrator, the error did not change.

Root cause: Workspace admin role assignments take minutes to take effect. During that window the API returns a 403 identical to a genuine permission failure.

Resolution: wait and retry. An unchanged apply succeeded about five minutes later.

Lesson: before redesigning around a permission error on a directory change, wait. Also worth knowing: refresh runs in the plan phase, so granting the apply identity more privilege does not fix a refresh failure.

A verification command that cannot fail

Problem: gcloud identity groups search --organization=<ORG_ID> returned nothing, both before and after a group existed.

Root cause: groups are parented to customers/<id>, so that query names a parent no group can ever have. It exits 0 and prints nothing, which is indistinguishable from "there are no groups".

Resolution: use the REST groups:search with parent=='customers/<id>', or gcloud identity groups describe by address.

Lesson: a check that cannot fail is not a check. If a command returns empty, confirm it can return non-empty before trusting the emptiness.

Cleanup and Key Takeaways

Cleanup

terraform destroy removes all six resources. Verify against the cloud rather than state: the group address should 404, the test service account should be gone, and the folder should carry no group: principal for the role. Commands are in the lab guide.

Two Workspace admin roles survive the destroy — Terraform does not manage the directory. Group Administrator on the apply identity can administer every group in the directory, so leaving it in place once the group is gone is a standing privilege with nothing to justify it. Revoke both by hand in Admin console → Account → Admin roles.

Preserved deliberately: the folder, the logging project and Week 2's federation setup — shared infrastructure later labs build on. Ongoing charges: none, verified $0 after teardown.

Key takeaways

  1. Directory administration is not cloud administration. No GCP role, including Organization Administrator, lets you manage a group. That authority lives in the Admin console and has no command-line path.
  2. An identity that cannot read a resource cannot manage it. A read-only plan identity is a sound control until the resource being planned lives in a system with no read-only role to offer.
  3. A permission error and a propagation delay are indistinguishable. Wait before redesigning around a 403.
  4. Membership changes took 10–30 seconds to affect real access. Fast, but not instant — an operator removing someone during an incident will see access persist briefly.
  5. Verify the command, not just the result. A query returning nothing because it asked the wrong parent looks exactly like one returning nothing because there is nothing there.

References

Comments

How was your experience?
Your feedback helps improve this site.
PoorExcellent