Simulation
Change the role, the grant scope, and the requested action to see how IAM scope and role breadth decide whether the engineer's request is allowed and how closely it matches least privilege.
Change the inputs and watch how the outcome changes.

Change the role, the grant scope, and the requested action to see how IAM scope and role breadth decide whether the engineer's request is allowed and how closely it matches least privilege.
The Pub/Sub Publisher predefined role carries only the permissions needed to publish, and granting it on orders-topic means the allow policy applies to exactly that one resource. This matches the principle of least privilege: no broader scope and no broader role than the task requires.
Starting scenarioEvery input at its default
Because the grant moved from the topic to the project, the allow policy is inherited by every child resource, so the engineer can now also publish to billing-topic. The request succeeds, but the grant exceeds the minimum necessary scope for someone who only needs orders-topic.
What changed
With the grant moved to the organization, the allow policy is inherited down the whole hierarchy, so the Publisher permissions now apply to matching resources in every project. This is only appropriate when a principal genuinely needs access across all projects — here it is far broader than publishing to one topic.
What changed
With the grant scope changed from the topic to the project and the role changed to the Editor basic role, the request is authorized — whichever action is requested. Basic roles bundle thousands of permissions across all Google Cloud services, so this grant works but violates least privilege; role recommendations and Policy Simulator can help replace it with a limited predefined or custom role.
What changed
Changing the grant scope to the organization and the role to the Editor basic role authorizes any action the engineer attempts, because the inherited allow policy grants thousands of permissions across every project. The request succeeds, but this is the broadest possible grant and should be avoided in production.
What changed
With the role changed to the basic Editor role, the grant no longer fits this scope: basic roles can only be set at the organization, folder, or project level, not on an individual Pub/Sub topic. Even if it could be applied, Editor would bundle thousands of unrelated permissions, so a narrow predefined role at the topic level is the better choice.
What changed
The role changed to a request on billing-topic while the Pub/Sub Publisher grant stays attached to orders-topic. A grant on one resource does not extend to sibling resources in the same project, so the topic-level allow policy never matches billing-topic and the request is denied by default.
What changed
With the action changed to deleting a Compute VM, the request is denied no matter which scope the Pub/Sub Publisher role is granted at: that predefined role contains only Pub/Sub permissions and nothing for Compute Engine. Authorization checks that the granted roles include the requested permission, not just that some role exists.
What changed
Roles, Permissions, and Allow Policies
An allow policy set on a parent resource, such as an organization or project, is inherited by its child resources. A grant at the project level therefore applies to every matching resource inside that project. Google Cloud offers three categories of roles that differ in breadth and control:
| Role type | Breadth | Choose when |
|---|---|---|
Basic roles, including Owner (roles/owner) | Thousands of permissions across all Google Cloud services | Broader access is needed for test or development, or nearly universal access is required |
| Predefined roles, such as Publisher or Project IAM Admin | Limited set of permissions for a specific service or job function | Production work needs only the permissions for that task |
| Custom roles | Customer-defined set of permissions | Predefined roles are too broad or too narrow for the need |
Domain 5 of 5
27 practice questions
Practice this DomainLast updated