Managing Cloud IAM: Roles, Policies, and Inheritance
Managing IAM in Google Cloud means controlling who (a principal) can do what (a role) on which resource, expressed as role bindings inside an allow policy attached somewhere in the organization, folder, project and resource hierarchy. Allow policies inherit downward and are additive: the effective access on a resource is the union of every binding on it and above it, and a lower-level allow policy can never subtract a role granted higher up. Only a separate deny policy can block an inherited permission. You choose among three role types: basic roles that span a whole project, predefined roles maintained by Google per service, and custom roles you assemble yourself. Every grant has two axes to get right, the narrowest role and the lowest attachment point. This lesson covers the policy model and principal identifiers, viewing and editing policies with gcloud (including the etag-protected set-iam-policy), IAM Conditions, the three role types and the near-twin predefined roles that are easy to confuse, inheritance and deny policies, and how to define and retire custom roles.
On this page10 sections
- The IAM policy model: principals, roles, and bindings
- Viewing and creating IAM policies with gcloud
- IAM Conditions: expiring and scoped grants
- Basic, predefined, and custom roles compared
- Choosing among near-twin predefined roles
- Policy inheritance in the organization hierarchy
- Deny policies: blocking permissions that allow policies grant
- Defining custom IAM roles
- A worked scenario: least privilege for a deployment team
- IAM concepts and role-type quick reference
- Describe the IAM policy model and write correct principal identifiers (user:, group:, serviceAccount:, domain:, allAuthenticatedUsers, allUsers)
- View policies with get-iam-policy and get-ancestors-iam-policy, edit them with add-/remove-iam-policy-binding, and replace them safely with set-iam-policy and the etag
- Write IAM Conditions for expiring access and resource-name scoping, including Cloud Storage object paths and RFC 3339 timestamps
- Compare basic, predefined and custom roles, and choose among near-twin predefined roles for Compute Engine, Cloud Storage, Cloud SQL, BigQuery and IAM administration
- Trace how allow policies inherit down the hierarchy, what changes when a project moves folders, and how deny policies block inherited permissions
- Diagnose access with Policy Troubleshooter rather than searching one policy for an email address
- Define custom roles at the project or organization level, respecting permission support levels, launch stages, disabling and deletion
The IAM policy model: principals, roles, and bindings
Cloud IAM answers one question, who can do what on which resource, with three building blocks. A principal (also called a member) is the identity requesting access. A role is a named bundle of permissions, where each permission is a verb on a service resource such as compute.instances.start or storage.objects.get. You never grant a permission directly to a principal: permissions travel only inside roles.
A role binding ties one role to a list of principals, and an allow policy (often just called the IAM policy) is the set of bindings attached to a single resource. Policies can attach at the organization, a folder, a project, or an individual resource that supports its own policy, such as a Cloud Storage bucket, a Pub/Sub topic or a service account. A binding can also carry an optional IAM condition that limits when the grant applies (covered below).
Principal identifiers and what each one covers
| Identifier | Who it covers | Typical use |
|---|---|---|
user:alice@example.com | One Google Account (Workspace, Cloud Identity or a personal account) | Rarely; prefer groups |
group:devs@example.com | Every member of a Google group, including nested groups | Job-function access managed through membership |
serviceAccount:app@PROJECT_ID.iam.gserviceaccount.com | One service account, identified by its email | Workloads |
domain:example.com | Every user account in the Workspace or Cloud Identity domain; not service accounts | Staff-wide read access |
allAuthenticatedUsers | Anyone signed in with any Google Account or any service account, including personal Gmail accounts outside your company | Effectively public; not a way to mean "our staff" |
allUsers | Everyone on the internet, authenticated or not | Deliberately public content |
Because allAuthenticatedUsers includes every Google Account in the world, it is not a staff-only setting: for company-only access use domain: or, better, a group:. Because domain: covers user accounts only, a service account that also needs the access must be granted with its own serviceAccount: member.
The member value must carry the right prefix and the right form. Common mistakes are a bare email with no prefix, user: in front of a service account's email, and a service account's resource name (projects/PROJECT_ID/serviceAccounts/EMAIL) where the member format serviceAccount:EMAIL is required. Roles are named in full too: predefined roles as roles/NAME, custom roles as projects/PROJECT_ID/roles/ROLE_ID or organizations/ORG_ID/roles/ROLE_ID.
Two consequences of the model come up constantly. Because permissions only travel inside roles, the fix for one missing permission is finding (or building) a role that carries it. Because the policy lives on the resource rather than on the person, working out what someone can do means examining policies across the hierarchy and through their group memberships, which is why the inheritance rules and Policy Troubleshooter matter.
Viewing and creating IAM policies with gcloud
You view an allow policy with get-iam-policy on the node you care about: gcloud projects get-iam-policy PROJECT_ID, gcloud resource-manager folders get-iam-policy FOLDER_ID, gcloud organizations get-iam-policy ORG_ID, or per-resource commands such as gcloud storage buckets get-iam-policy gs://my-bucket. Each prints the bindings set on that one node only (roles, principals, conditions) plus an etag. It does not show grants inherited from ancestors, and it shows groups, not the people inside them. To see a project's own policy and every ancestor's policy in one call, use gcloud projects get-ancestors-iam-policy PROJECT_ID. The Console IAM page also labels inherited grants with the level they come from.
Granting and revoking one binding
To grant a role, add a binding: gcloud projects add-iam-policy-binding PROJECT_ID --member=group:devs@example.com --role=roles/compute.instanceAdmin.v1. To revoke, use remove-iam-policy-binding with the same flags. These helpers read the current policy, change one binding and write it back, so they are the safe day-to-day tool. Equivalent commands exist for folders, organizations and individual resources.
When the same member and role appear in conditional bindings, you must say which binding to remove: --condition=None removes only the unconditional binding, --condition=EXPRESSION (with its title and description) removes the binding that matches exactly, and --all removes every binding of that role for that member regardless of condition.
Replacing the whole policy: set-iam-policy and the etag
gcloud projects set-iam-policy PROJECT_ID policy.json writes the file as the entire allow policy: any binding missing from the file is removed. The safe pattern is read-modify-write: export with get-iam-policy --format=json > policy.json, edit, then set. The exported etag identifies the version you read. If someone else changed the policy in between, the etag no longer matches and the write fails; you re-read, re-apply your edit and retry. If you delete the etag from the file, the write is unconditional and silently overwrites any concurrent change.
Who may edit a policy, and how to diagnose access
Changing a policy needs the setIamPolicy permission on that resource, which comes from Owner or an IAM-administration role (compared in a later section). To answer "why can (or can't) this person do X here?", use Policy Troubleshooter: give it a principal email, a full resource name and a permission (in the Console, or gcloud policy-troubleshoot iam RESOURCE --principal-email=EMAIL --permission=PERMISSION). It evaluates the bindings that actually apply, including grants inherited from folders and the organization and grants that reach the person through group membership. Searching get-iam-policy output for the person's email misses both. IAM Recommender complements it by suggesting tighter roles based on permissions actually used.
IAM Conditions: expiring and scoped grants
An IAM condition is a Common Expression Language (CEL) expression on a role binding; the binding grants its role only while the expression is true. You add one with --condition='expression=EXPR,title=TITLE' on add-iam-policy-binding. The two patterns you meet most are time limits and resource scoping.
- Expiring access:
request.time < timestamp("2027-12-31T00:00:00Z").timestamp()is a point in time;duration()(for exampleduration("86400s")) is a length of time used in arithmetic with a timestamp, so an expiry is compared against a timestamp, not a bare duration. - Timestamps are RFC 3339 with an offset.
Zmeans UTC. A non-zero offset moves the cutoff:2027-12-31T00:00:00+05:00is 19:00 UTC on 30 December. - Resource scoping:
resource.name.startsWith("...")limits a grant to matching resources. For Cloud Storage objects the resource name has the formprojects/_/buckets/BUCKET/objects/OBJECT, so a prefix condition for a folder of objects must includeobjects/, for exampleresource.name.startsWith("projects/_/buckets/reports/objects/finance/"). Two prefixes fail in practice: one that leaves outobjects/, such asprojects/_/buckets/reports/finance/, matches no object at all; and a bucket-only prefix with no trailing slash, such asprojects/_/buckets/reports, also matches other buckets whose names start the same way, such asreports-archive. Conditions on Cloud Storage resources also require uniform bucket-level access on the bucket; a bucket that still uses fine-grained ACLs cannot carry conditional bindings.
An expired time condition is not deleted from the policy: the binding stays until someone removes it, it simply grants nothing. It switches off only its own binding; if the same person still holds the role another way, for example through a group binding without a condition, that access continues.
Basic, predefined, and custom roles compared
The three role types differ in who defines them, how broad they are, and when you should reach for each.
| Type | Defined by | Examples | Scope of powers | When to use |
|---|---|---|---|---|
| Basic | Google (legacy, project-wide) | roles/viewer, roles/editor, roles/owner | Thousands of permissions across every service in the project | Rarely, for quick experiments; they violate least privilege in production |
| Predefined | Google, per service | roles/compute.instanceAdmin.v1, roles/storage.objectViewer, roles/pubsub.publisher | A curated permission set for one job on one service, kept current by Google as services add features | The default choice for almost every grant |
| Custom | You, at project or organization level | A role holding exactly compute.instances.start and compute.instances.stop | Precisely the permissions you list, and only those | When no predefined role matches the required permission set |
The basic roles predate modern IAM, and their reach is wider than people expect: Editor grants modify access to nearly all services in the project (but not management of IAM policies), and Owner adds managing IAM and granting roles to others. Billing management is handled separately through billing account roles. Handing a person or a service account Editor to solve a narrow task is the classic least-privilege violation when a predefined role covers the job.
Predefined roles carry a maintenance advantage custom roles never get: when a service launches new permissions, Google updates its predefined roles so holders keep working. A custom role is frozen at the permissions you listed, and you own its upkeep. Reach for a custom role only when least privilege genuinely demands a combination no predefined role offers. To see exactly what a role contains (rather than who holds it), run gcloud iam roles describe roles/storage.objectViewer.
Choosing among near-twin predefined roles
Least privilege usually comes down to choosing between predefined roles with similar names. The deciding question is which resources the job touches and whether it reads, creates or administers them.
Compute Engine
| Role | What it allows |
|---|---|
roles/compute.instanceAdmin.v1 | Full control of VM instances, instance groups, disks, snapshots and images; read-only on networking. The usual role for teams that run VMs. |
roles/compute.admin | Full control of all Compute Engine resources, including networks, firewalls and load balancing. Much broader. |
roles/compute.storageAdmin | Disks, images and snapshots only; no instance control. |
roles/compute.osAdminLogin | Signs in to VMs through OS Login with administrator (sudo) rights; manages no resources. roles/compute.osLogin is the non-admin version. |
Cloud Storage, Cloud SQL and BigQuery
| Role | What it allows |
|---|---|
roles/storage.objectViewer | List and read objects. |
roles/storage.objectCreator | Create (upload) objects only; cannot read, overwrite or delete them. Suits a write-only drop. |
roles/storage.objectAdmin | Full control of objects, including delete; does not manage bucket settings. |
roles/storage.admin | Full control of buckets and objects, including bucket IAM policies. |
roles/cloudsql.client | Connect to instances through the Cloud SQL Auth Proxy or connectors. |
roles/cloudsql.instanceUser | Log in to the database with IAM database authentication (cloudsql.instances.login). An IAM login through the Auth Proxy typically needs both roles. |
roles/bigquery.dataViewer | Read table data and metadata; grantable on a dataset, or even on a single table or view. |
roles/bigquery.jobUser | Run jobs, including queries; grantable only on a project, folder or organization. |
Each role also has a lowest level it can be granted at. BigQuery is the standard example: data access can be granted on the dataset (or a single table), but the right to run query jobs is granted on the project whose jobs are billed, so an analyst querying one dataset typically needs both grants at their two different levels.
IAM administration roles
| Role | Scope |
|---|---|
roles/resourcemanager.projectIamAdmin | Get and set the allow policy of projects. Granted on a folder, it is inherited by every project inside, so it is how you let someone manage child projects' IAM. |
roles/resourcemanager.folderIamAdmin | Get and set the folder's own allow policy. Bindings written there reach every project below by inheritance, but this role does not let you edit the projects' own policies. |
roles/iam.securityAdmin | Get and set any IAM policy within its scope. |
roles/iam.securityReviewer | List all resources and read their allow policies; no changes. Suits auditors. |
roles/iam.roleAdmin / roles/iam.roleViewer | Create and manage, or read, custom role definitions; neither grants roles to anyone. |
roles/iam.denyAdmin | Create and manage deny policies; granted on the organization. |
Policy inheritance in the organization hierarchy
Allow policies inherit down the resource hierarchy: a binding on the organization applies to every folder, project and resource beneath it; a binding on a folder applies to all projects inside it; a binding on a project applies to every resource in the project. The effective policy on any resource is the union of the policy set directly on it and every policy inherited from its ancestors.
Inheritance is additive. An allow policy only ever grants, so a lower level cannot narrow what an ancestor granted. If devs@example.com holds roles/editor on the folder, granting the same group roles/viewer on one project inside it changes nothing: the group still holds Editor there. Editing the child project's allow policy can never remove inherited access. The fixes are to change the grant where it was made (for example, replace the folder binding with bindings on only the projects that need it), to change the membership that carries it (move one person out of the group that holds the folder grant and grant them directly where they still need access), or to block specific permissions with a deny policy, described next.
Moving a project to another folder changes what it inherits: bindings on the old folder stop applying the moment the move completes, and the new parent's bindings start applying. The project's own policy travels with it unchanged. Before a move, check that no one depended on the old folder's grants and that the new folder does not grant more than intended.
Every grant has two axes, and both must be right: pick the narrowest role and bind it at the lowest node whose subtree matches the requirement. A correct role on the wrong node still over-grants: a folder binding reaches every current and future project in the folder. Grant high only when the whole subtree needs the access; an organization-wide audit team might hold roles/iam.securityReviewer on the organization, while a contractor auditing one bucket gets roles/storage.objectViewer on that bucket. When a department's twelve projects all need the same access, one binding on the department's folder beats twelve project bindings kept in sync by hand.
Deny policies: blocking permissions that allow policies grant
An IAM deny policy is a set of deny rules that stop named principals from using specific permissions, whatever their allow policies grant. It is the standard way to take away specific permissions that are granted higher up the hierarchy without changing that grant. (Principal access boundary policies can also limit access, but they work differently: they restrict which resources a set of principals can reach, not which permissions they can use.)
- Permissions, not roles. A deny rule lists the permissions it denies (written in a fully qualified form such as
cloudresourcemanager.googleapis.com/projects.delete), the principals it applies to, and optional exception principals. - Attach points: the organization, a folder or a project only, not individual resources such as buckets. Like allow policies, deny policies are inherited by everything below.
- Evaluated first. IAM checks deny policies before allow policies. If a deny rule applies, the request is refused even for a principal holding Owner; no allow grant overrides a deny.
- Exceptions win within the rule. A principal listed as an exception is not denied by that rule, even if it is also a member of a denied group. That is how you block a permission for "all engineers except the break-glass group".
- Who manages them: creating and editing deny policies needs
roles/iam.denyAdmin(Deny Admin), granted on the organization. Project or folder IAM admin roles do not include it.
Use allow-policy design for ordinary least privilege, and keep deny policies for guardrails: blocking a dangerous permission across a folder, or carving one team out of an inherited grant you cannot change.
Defining custom IAM roles
A custom role is a permission bundle you define when least privilege requires a combination no predefined role offers, for example operators who may start and stop VMs but never create or delete them. Custom roles are created at the project level or the organization level, never at the folder level. A project-level custom role can only be used in bindings within that project; an organization-level role can be used anywhere in the organization, so define shared roles once there rather than cloning them per project. A project-level role also cannot grant permissions that act only at the folder or organization level (for example resourcemanager.organizations.get), because a project has nothing for them to act on.
Create one with gcloud iam roles create vmOperator --project=PROJECT_ID --title="VM Operator" --permissions=compute.instances.start,compute.instances.stop --stage=GA, or from a YAML file with --file; use --organization=ORG_ID for an organization role. Because custom role IDs are scoped, other commands also need the scope: gcloud iam roles describe vmOperator --project=PROJECT_ID. Useful companions: gcloud iam list-testable-permissions RESOURCE lists permissions usable on a resource with their support level, and gcloud iam roles copy clones a role you can then trim.
Permission support levels
Every permission has a custom-role support level. SUPPORTED permissions are fully supported in custom roles. TESTING permissions can be included but are being tested for compatibility and may behave unexpectedly, so avoid them in production roles. NOT_SUPPORTED permissions cannot be included in a custom role at all; they are only available through predefined roles.
Launch stages, disabling and deletion
| Stage or action | Effect on access |
|---|---|
ALPHA, BETA, GA | Labels of maturity only. They do not block grants or withhold permissions: an ALPHA role grants everything in it as soon as it is bound. |
DEPRECATED | A warning to admins not to use the role for new grants; existing bindings keep working. |
DISABLED | The role stays in every policy that references it, but those bindings grant nothing. Setting the stage back re-activates them. The right tool for a temporary suspension. |
Delete (gcloud iam roles delete) | Bindings stop granting; the role can be restored with gcloud iam roles undelete only during a short window (7 days), after which deletion becomes permanent. |
So DISABLED is the only launch stage that changes enforcement. Update roles with gcloud iam roles update, and remember that Google never adds new permissions to your custom roles: when a service evolves, your role stays as you wrote it.
A worked scenario: least privilege for a deployment team
Scenario: your company has an organization with a retail folder containing the projects retail-prod, retail-staging and retail-dev. The deployment team must manage Compute Engine instances in all three projects; the data science group needs read-only access to one Cloud Storage bucket in retail-prod; and a new platform admin must be able to grant roles across the whole retail estate. How do you set this up without basic roles?
The deployment team needs the same service-specific power in every project under the folder, so bind once at the folder: gcloud resource-manager folders add-iam-policy-binding FOLDER_ID --member=group:deploy@example.com --role=roles/compute.instanceAdmin.v1. Inheritance carries it into all three projects and any future project in the folder. The data science group's need is the narrowest, so bind at the resource itself: roles/storage.objectViewer on the single bucket, not on retail-prod, where it would expose every bucket in the project. The platform admin must edit IAM at two kinds of node: roles/resourcemanager.folderIamAdmin on the folder covers the folder's own policy, and roles/resourcemanager.projectIamAdmin granted on the folder is inherited by every project inside, covering their policies. Neither role grants access to the resources themselves.
The habits embedded here: every grant went to a group, so team changes are membership edits rather than IAM edits; every grant used a predefined role scoped to one job; and every grant landed at the lowest node that satisfies the whole requirement. If the deployment team later needed start/stop only, that is the trigger to define an organization-level custom role and swap the folder binding to it. If one person must lose the folder-wide access but keep it in retail-dev, remove them from deploy@ and grant them directly on retail-dev.
IAM concepts and role-type quick reference
Use this reference to compress the lesson into the facts that decide most IAM scenarios.
| Concept | What it is | Key fact |
|---|---|---|
| Principal | Identity granted access: user, group, service account, domain, allAuthenticatedUsers, allUsers | Prefer groups; allAuthenticatedUsers is effectively public; domain: excludes service accounts |
| Role | Named bundle of permissions | Permissions are never granted directly |
| Binding | One role tied to a list of principals, optionally with a condition | An expired condition stays in the policy and disables only its own binding |
| Allow policy | All bindings attached to one resource | get-iam-policy shows one node; get-ancestors-iam-policy adds the ancestors; set-iam-policy replaces it all (etag-protected) |
| Effective policy | Union of the resource's policy and all inherited ancestor policies | Additive; a child allow policy cannot remove an inherited grant |
| Deny policy | Denied permissions for principals, with exceptions, on org, folder or project | Checked before allow; Owner does not override it; managed with Deny Admin on the org |
| Basic roles | Owner, Editor, Viewer across the whole project | Avoid in production |
| Predefined roles | Google-maintained, service-specific | The default least-privilege choice |
| Custom roles | Your own permission list, project- or organization-level | No folder-level custom roles; NOT_SUPPORTED permissions excluded; you maintain them |
| Launch stage | ALPHA, BETA, GA, DEPRECATED, DISABLED on a custom role | Only DISABLED changes enforcement: its bindings grant nothing |
A reliable triage for any IAM scenario: identify the principal (prefer a group, use the right prefix), identify the narrowest role that carries the needed permissions (predefined before custom, custom before basic), then identify the lowest attachment point whose subtree matches the requirement. If someone has more access than a project's policy suggests, look for inheritance or a group, and confirm with Policy Troubleshooter. If inherited access must be blocked without changing the grant, that is a deny policy.
Tip. Scenarios turn on where a binding attaches (one folder grant versus many project grants, or a correct role at too high a node) and on why someone keeps access a project admin tried to remove: additive inheritance or a group, confirmed with Policy Troubleshooter, and blocked if necessary with a deny policy. Expect choices between near-twin predefined roles (Compute Engine instance vs full admin, Cloud Storage object roles, Cloud SQL client vs instance user, BigQuery data vs job roles, project vs folder IAM admin) and between principal identifiers (allAuthenticatedUsers, domain:, the serviceAccount: format). Know the gcloud verbs (get-iam-policy, get-ancestors-iam-policy, add-/remove-iam-policy-binding with conditions, set-iam-policy with the etag), IAM Condition syntax and timestamps, and the custom-role facts: project or organization level only, permission support levels, and that only DISABLED changes enforcement.
- An allow policy is a set of role bindings on one resource; each binding ties one role to principals, optionally with a condition
- Use the right principal form: group: for teams, serviceAccount:EMAIL for service accounts; allAuthenticatedUsers is any Google account (effectively public) and domain: excludes service accounts
- Allow-policy inheritance is additive: a child's allow policy cannot remove an inherited grant; change the grant at its source, change group membership, or use a deny policy
- Deny policies deny permissions at the organization, folder or project, are checked before allow policies, honour exception principals, override even Owner, and are managed with Deny Admin on the organization
- get-iam-policy shows one node; get-ancestors-iam-policy adds the ancestors; Policy Troubleshooter evaluates inherited and group-based grants for one principal and permission
- set-iam-policy replaces the whole policy; keep the etag so a write based on a stale read fails instead of overwriting someone else's change
- Pick the narrowest predefined role and bind it at the lowest node; a correct role on a folder still reaches every project in it
- Custom roles live at the project or organization level only; NOT_SUPPORTED permissions cannot be included, and only the DISABLED stage stops a role's bindings from granting anything
Frequently asked questions
What is the difference between basic, predefined, and custom roles, and when should I create a custom role?
Basic roles (Owner, Editor, Viewer) are legacy project-wide roles spanning thousands of permissions across every service, so they violate least privilege. Predefined roles are Google-maintained, service-specific bundles such as roles/storage.objectViewer, kept up to date as services evolve, and are the default choice. Custom roles are permission lists you define at the project or organization level (never a folder) when no predefined role fits; you maintain them yourself and cannot include NOT_SUPPORTED permissions. Create a custom role only when no predefined role fits least privilege: start from a close predefined role (inspect it with gcloud iam roles describe), add or remove permissions, and define roles shared across projects at the organization level so there is one copy to maintain.
How does IAM policy inheritance work in the Google Cloud hierarchy?
Allow policies attached to the organization, a folder or a project are inherited by everything beneath them, and the effective policy on a resource is the union of its own policy and all inherited ones. Inheritance is additive, so a child's allow policy cannot remove an inherited role. Moving a project to another folder swaps the inherited policies: the old folder's bindings stop applying and the new folder's start applying.
Can I remove access in one project that a user inherits from a folder?
Not by editing the project's allow policy, because allow policies only add access. You can change the folder binding itself (for example, bind only the projects that need it), take the person out of the group that holds the folder grant and grant them directly where they still need access, or create a deny policy on the project that denies the specific permissions. Deny policies are checked before allow policies and apply even to Owners.
What does an IAM deny policy do?
A deny policy stops listed principals from using listed permissions, whatever their allow policies grant. It attaches to an organization, folder or project (not to individual resources such as buckets), is inherited downward, and is evaluated before allow policies. Exception principals are exempt from a rule even if they belong to a denied group. Managing deny policies requires the Deny Admin role (roles/iam.denyAdmin) granted on the organization.
How do I grant or remove an IAM role with gcloud?
Use gcloud projects add-iam-policy-binding PROJECT_ID --member=group:team@example.com --role=roles/compute.instanceAdmin.v1, and remove-iam-policy-binding with the same flags to revoke. The member needs a prefix (user:, group:, serviceAccount:, domain:) and the role its full name. If conditional bindings exist for that member and role, add --condition=None, --condition=EXPRESSION or --all to say which to remove. Equivalent commands exist for folders, organizations and individual resources.
Why does set-iam-policy need an etag?
set-iam-policy replaces the whole allow policy with the file you supply, so it must be based on the current version. The etag from get-iam-policy identifies the version you read; if the policy changed since then, the write fails and you re-read, re-apply your edit and retry. Removing the etag makes the write unconditional, which can silently erase someone else's change. For single grants, add-iam-policy-binding is simpler and safer.
How do I give someone temporary IAM access?
Add an IAM condition to the binding, such as request.time < timestamp("2027-12-31T00:00:00Z"). The timestamp is RFC 3339: Z means UTC and an offset such as +05:00 shifts the cutoff. After the time passes, the binding stays in the policy but grants nothing, and it only switches off itself, so access the person holds through another binding, such as a group, continues.
What happens to bindings when a custom role is disabled or deleted?
A DISABLED custom role stays in every policy that references it, but those bindings grant no permissions until the stage is changed back, which makes it the right tool for a temporary suspension. ALPHA, BETA, GA and DEPRECATED do not affect enforcement. A deleted role can be restored with gcloud iam roles undelete only for a short period (7 days) before deletion becomes permanent.
Source
This lesson covers the "Configuring access and security" domain of the official ACE exam guide. Vendors revise their guides — check the source for the current version.
- Google Cloud Associate Cloud Engineer exam guide — Google Cloud
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.