Google Cloud offers Identity and Access Management (IAM), which lets you give more granular access to specific Google Cloud resources and prevents unwanted access to other resources. IAM lets you adopt the security principle of least privilege, so you grant only the necessary access to your resources.
IAM lets you control who (users) has what access (roles) to which resources by setting allow policies. Allow policies grant specific roles to a user to give the user certain permissions.
This page explains the IAM roles that are available on the organization resource, and how to create and manage allow policies for organization resources using the Cloud Resource Manager API. For more information, see Manage access to projects, folders, and organizations.
Permissions and roles
To control access to resources, Google Cloud requires that accounts making API
requests have appropriate IAM roles. IAM roles
include permissions that let users perform specific actions on
Google Cloud resources. For example, the
resourcemanager.organizations.get permission allows a user to get details
about their organization resource.
You don't directly give users permissions; instead, you grant them roles, which have one or more permissions bundled within them.
You can grant one or more roles on the same resource.
Use predefined roles
The following table lists the roles that you can grant to access an organization resource's properties, the description of what the role does, and the permissions bundled within that role.
| Role | Permissions |
|---|---|
Organization Administrator( Access to manage IAM policies and view organization policies for organizations, folders, and projects. Lowest-level resources where you can grant this role:
|
|
Organization Viewer( Provides access to view an organization. Lowest-level resources where you can grant this role:
|
|
Organization Policy Administrator( Provides access to define what restrictions an organization wants to place on the configuration of cloud resources by setting Organization Policies. Lowest-level resources where you can grant this role:
|
|
Browser( Read access to browse the hierarchy for a project, including the folder, organization, and allow policy. This role doesn't include permission to view resources in the project. Lowest-level resources where you can grant this role:
|
|
Creating custom roles
In addition to the predefined roles described in this topic, you can also create custom roles that are collections of permissions that you tailor to your needs. When creating a custom role for use with Resource Manager, be aware of the following points:- List and get permissions, such as
resourcemanager.projects.get/list, should always be granted as a pair. - When your custom role includes the
folders.listandfolders.getpermissions, it should also includeprojects.listandprojects.get. - Be aware that the
setIamPolicypermission for organization, folder, and project resources allows the user to grant all other permissions, and so should be assigned with care.
View existing access for an organization resource
You can view what roles a user is granted for an organization resource by
getting that resource's allow policy. You can view the allow policy for an
organization resource using the Google Cloud console, the Google Cloud CLI,
or the getIamPolicy()
method.
Console
To view granted roles at the organization resource level using the Google Cloud console:
Go to the Manage resources page in the Google Cloud console:
On the Organization drop-down menu, select your organization resource.
Select the checkbox for the organization resource.
In the Info Panel, under Permissions, click Expand a role and display all members who have that role.
gcloud
Get the allow policy for the organization resource using the get-iam-policy command:
gcloud organizations get-iam-policy \
ORGANIZATION_ID --format json > \
FILENAME.JSON
The command outputs the allow policy, which looks similar to the following:
bindings:
- members:
- user:testuser1@gcp-test.com
role: roles/editor
- members:
- user:admin@gcp-test.com
role:roles/resourcemanager.organizationAdmin
- members:
- user:testuser2@gcp-test.com
role: roles/resourcemanager.projectCreator
etag": "BwU1aRxWk30="
API
The following code snippet returns the allow policy for the organization
resource
https://cloudresourcemanager.googleapis.com/v3/organizations/12345.
Request:
POST
https://cloudresourcemanager.googleapis.com/v3/organizations/12345:getIamPolicy
Response:
{
"bindings": [
{
"role": "roles/resourcemanager.organizationAdmin",
"members": [
"user:email1@gmail.com"
]
},
{
"role": "roles/resourcemanager.projectCreator",
"members": [
"user:email2@gmail.com",
"user:email3@gmail.com",
"serviceAccount:my-other-app@appspot.gserviceaccount.com"
]
}
]
"etag": "BwUjHYKHHiQ="
}
Python
The method
getIamPolicy()
lets you get an allow policy that was previously set.
crm = discovery.build(
'cloudresourcemanager', 'v3', http=creds.authorize(httplib2.Http()))
policy = crm.organizations().getIamPolicy(
resource=flags.organizationId, body={}).execute()
print json.dumps(policy, indent=2)
Grant access to an organization resource
Organization Administrators can grant IAM roles to team members
so that they can access an organization's resources and APIs. You can grant
roles to a user account email, a Google Group, a service account, or a G Suite
domain. You can use the Google Cloud console, the gcloud CLI, or
the
setIamPolicy()
method to grant roles.
Console
To set access control at the organization resource level using the Google Cloud console:
Go to the Manage resources page in the Google Cloud console:
On the Organization drop-down menu, select your organization resource.
Select the checkbox for the organization resource. If you don't have a folder resource, the organization resource is not visible. To continue, see the instructions for granting roles through the IAM page.
If the Info Panel on the right is hidden, click Show Info Panel in the top right corner.
In the Info Panel, in the Permissions tab, click Add Member.
In the New members field, enter the team members you want to add. You can specify a user account email, a Google Group, a service account, or a G Suite domain.
In the Select a role drop-down menu, select the role you want to grant to the team members.
Click Add.
gcloud
To set an organization resource's allow policy using the gcloud command:
Get the allow policy for the organization resource using the
get-iam-policycommand and output the policy to a JSON file:gcloud organizations get-iam-policy \ ORGANIZATION_ID \ --format json > FILENAME.JSONThe contents of the JSON file looks similar to the following:
{
"bindings": [
{
"members": [
"user:testuser1@gcp-test.com"
],
"role": "roles/editor"
},
{
"members": [
"user:admin@gcp-test.com",
],
"role": "roles/resourcemanager.organizationAdmin"
},
{
"members": [
"user:testuser2@gcp-test.com"
],
"role": "roles/resourcemanager.projectCreator"
},
],
"etag": "BwU1aRxWk30="
}
- Open the JSON file in a text editor. Then, add a new entry to the
bindingsarray to define an Organization Administrator. For example, to makeanotheradmin@gcp-test.coman Organization Administrator, change the previous example as follows:
{
"bindings": [
{
"members": [
"user:testuser1@gcp-test.com"
],
"role": "roles/editor"
},
{
"members": [
"user:admin@gcp-test.com",
"user:anotheradmin@gcp-test.com"
],
"role": "roles/resourcemanager.organizationAdmin"
},
{
"members": [
"user:testuser20@gcp-test.com"
],
"role": "roles/resourcemanager.projectCreator"
},
],
"etag": "BwU1aRxWk30="
}
- Update the organization resource's allow policy by running the following command:
gcloud organizations set-iam-policy \
ORGANIZATION_ID policy.json
API
Request:
POST https://cloudresourcemanager.googleapis.com/v3/organizations/12345:setIamPolicy
{
"policy": {
"version": "0",
"bindings":