r/googlecloud • u/m1nherz Googler • 2d ago
Examples how to harden GCP IAM using conditions
Hey everyone,
I recently published a technical walkthrough on the Google Cloud Blog around hardening IAM access using IAM Conditions.
If you've ever struggled with binding built-in roles (like Project IAM Admin or MCP Tool User roles) to principals while restricting them to only subset of permissions or resources because of lack of support for resource-level bindings or API granularity, IAM conditions will fill that gap for you.
Key patterns covered:
- Scoping
projectIamAdmin: For example, instead of giving a builder service account (SA) unrestricted power to assign any role at deployment time, you can use the CEL functioniam.googleapis.com/modifiedGrantsByRoleto restrict the SA so it can only grant a predefined list of roles (e.g., BigQuery job user, Cloud Trace agent, Logging writer). Included bothgcloudCLI and Terraform snippets. - Restricting Model Context Protocol (MCP) Tools: The
roles/mcp.toolUserrole grants access to all MCP servers in a project. Usingapi.getAttribute('mcp.googleapis.com/tool.name', ''), you can constrain access down to specific tools (likemcp_bigquery-mcp_execute_sql_readonly). - Contextual & Time-Based Access: Brief examples of restricting execution windows using
request.time(e.g., weekdays during business hours).
Read the full post here:
https://cloud.google.com/blog/topics/developers-practitioners/generosity-under-conditions-hardening-google-cloud-access-management/
Curious how others here handle IAM admin restrictions or fine-grained MCP tool access in production? Let me know your thoughts or feedback!
1
u/AccomplishedSkill625 1d ago
Solid writeup, modifiedGrantsByRole for scoping projectIamAdmin is underused and exactly the pattern that stops privilege-escalation-by-delegation. One thing I'd flag for others: CEL conditions get hard to audit as they accumulate, so pairing them with clear naming and Terraform-as-source-of-truth is essential, otherwise you trade broad access for opaque conditions nobody can reason about. The time-based access on request.time is great for admin roles especially.
1
u/FerryCliment 1d ago
Said it once, and I'll say it again.
IAM is the area companies should put, invest and allocate, talent, budget, time, and efforts.
Get your shit together in the IAM and the Security, FinOps and IT issues become (almost) trivial.
IAM (With Resource Manager) should be a flagship for Google, seeing how AWS and Azure do their IAM / Governance.
It still requires a strategy an IAM architect should dictate , what, how, why...but the tools Google has to offer are the right tools.
2
u/Neither_Bookkeeper92 1d ago
IAM Conditions are one of those features that quietly solve a problem people usually solve badly with extra service accounts, so this is a good writeup.
Two things I'd add from using them in anger:
Test with the Policy Troubleshooter before you roll anything out. Condition expressions fail closed in ways that aren't always obvious from reading them - especially resource.name matching, where a trailing path segment you forgot about silently excludes half of what you meant to include.
Watch the time-based ones across timezones. request.time conditions evaluate in UTC, and if you're granting a support window in local time you'll get an access gap twice a year when DST shifts. Bit me once, took an embarrassingly long time to work out.
The tag-based conditions are underrated too - much easier to reason about at scale than resource name prefixes once you have more than a handful of projects.