For example, I could provide you the privilege or role of compute viewer. This role provides you with read-only access to enlist Compute Engine resources without reading the data stored on them.
Cloud
To better understand where these objects fit, let’s look at the Cloud IAM resource hierarchy.
Google Cloud Platform resources are arranged hierarchically, as shown below.
The organization junction is the origin of the hierarchy.
Folders are the descendants of the organization.
Projects are the descendants of the folders, and the individual resources are the descendants of projects.
Cloud IAM authorizes you to set policies at all levels where a policy contains a set of roles and role members.
Let’s go through each level from top to bottom, because resources inherit policies from their parent.
The organization resource represents your company. All resources inherit Cloud IAM roles granted at this level under organization.
The folder resource can represent your department, and all resources inherit Cloud IAM roles given at this level that the folder contains.
Projects represent a security barrier within your company. Services inside the corresponding project have a default level of security.
The IAM policy hierarchy always reflects the same route as the resource hierarchy. If you modify the resource hierarchy, the policy hierarchy will also change.
For example, moving a project to a different organization will update the project’s IAM policy to receive from the new organization’s IAM. Downward policies cannot restrict access granted at the origin level.
Suppose I allow you the editor role for Department X and the viewer role at the setup-box-de (as shown in the last image) project level. You will still have the editor role for that project.
Hence, it is best to follow the rule of least privilege. The regulation applies to identities, roles, and resources. Always select the smallest scope necessary for the task to reduce your risk exposure.