Assigning a role to a user group
Assign a role to a user group to grant access to a resource. To grant group access permissions to a subject, see Configuring group management access.
In Yandex Identity Hub, you can assign a group a role for an organization, cloud, folder, another group, or service account.
Assigning a role for a cloud or folder
-
Log in to the management console
with the cloud administrator or owner account. -
On the left side of the screen, click the line with the name of the cloud or folder for which you want to assign a role to a user group.
-
At the top of the screen, go to the Access bindings tab and click Configure access. In the window that opens:
-
Go to the Groups tab and select the group you need or search by group name.
You can also assign a role to one of the system groups:
All users in organization X: The group includes all users in organizationX.All users in federation N: The group includes all users in federationN.
-
Click
Add role and select the role you want to assign to the group for the cloud or folder you selected earlier. You can assign multiple roles. -
Click Save.
-
If you do not have the Yandex Cloud CLI yet, install and initialize it.
-
Select a role from the Yandex Cloud role reference.
-
Assign a role using this command:
yc <service_name> <resource> add-access-binding <resource_name_or_ID> \ --role <role_ID> \ --subject group:<group_ID>Where:
-
--role: Role ID, e.g.,resource-manager.clouds.owner. -
--subject: Subject getting the role.Subject designations
To indicate a subject, use the
--subjectparameter in<subject_type>:<ID>format. For some subject types, the Yandex Cloud CLI provides separate parameters instead of--subject, where you only need to specify the subject name or ID without the type. Possible subject designations and the corresponding CLI parameters:Subject type
Subject designation
Yandex Cloud CLI parameter
userAccountuserAccount:<user_ID>--user-account-idor--user-yandex-loginserviceAccountserviceAccount:<service_account_ID>--service-account-idor--service-account-namefederatedUserfederatedUser:<user_ID>--user-account-idgroupgroup:<group_ID>--group-memberssystemsystem:allAuthenticatedUsers(
All authenticated usersgroup)--all-authenticated-userssystem:allUsers(
All usersgroup)—
system:group:organization:<organization_ID>:users(
All users in organization Xgroup)--organization-userssystem:group:federation:<federation_ID>:users(
All users in federation Ngroup)--federation-userssystem:group:userpool:<pool_ID>:users(
All users in userpool Pgroup)—
For example, assign the
resource-manager.viewerrole for themy-cloudcloud.yc resource-manager cloud add-access-binding mycloud \ --role resource-manager.viewer \ --subject group:aje6o61dvog2******** -
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), authenticate using the appropriate method.
-
Add the resource parameters to the configuration file and specify the required role and group:
resource "yandex_resourcemanager_cloud_iam_member" "admin" { cloud_id = "<cloud_ID>" role = "<role_ID>" member = "group:<group_ID>" }Where:
-
cloud_id: Cloud ID. To assign a role for a folder, use theyandex_resourcemanager_folder_iam_memberresource and specifyfolder_id. -
role: Role to assign. This is a required setting. -
member: Subject getting the role. This is a required setting.Subject designations
To indicate a subject, use a combination of its type and unique ID, i.e.,
<subject_type>:<ID>. How you can designate a subject:Subject type
Subject designation
userAccountuserAccount:<user_ID>serviceAccountserviceAccount:<service_account_ID>federatedUserfederatedUser:<user_ID>groupgroup:<group_ID>systemsystem:allAuthenticatedUsers(
All authenticated usersgroup)system:allUsers(
All usersgroup)system:group:organization:<organization_ID>:users(
All users in organization Xgroup)system:group:federation:<federation_ID>:users(
All users in federation Ngroup)system:group:userpool:<pool_ID>:users(
All users in userpool Pgroup)
For more on the properties of the
yandex_resourcemanager_cloud_iam_memberandyandex_resourcemanager_folder_iam_memberresources, see the relevant provider guide for the cloud and folder. -
-
Create the resources:
-
In the terminal, navigate to the configuration file directory.
-
Make sure the configuration is correct using this command:
terraform validateIf the configuration is valid, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
-
Apply the configuration changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
With this done, the specified access permissions will be assigned. You can check the role assignment using the management console
or this CLI command:yc resource-manager <cloud_or_folder> list-access-bindings <name_or_ID_of_cloud_or_folder> -
To assign a role for a cloud to a group of users, use the updateAccessBindings REST API method for the Cloud resource or the CloudService/UpdateAccessBindings gRPC API call.
To assign a role for a folder to a group of users, use the updateAccessBindings REST API method for the Folder resource or the FolderService/UpdateAccessBindings gRPC API call.
Provide the following in the request:
-
ADDvalue in theaccessBindingDeltas[].actionparameter to add a role. -
Role in the
accessBindingDeltas[].accessBinding.roleIdparameter. -
ID of the subject getting the role in the
accessBindingDeltas[].accessBinding.subject.idparameter. -
Type of the subject getting the role in the
accessBindingDeltas[].accessBinding.subject.typeparameter.Subject designations
To indicate a subject, use a combination of its type and unique ID in the
subject.typeandsubject.idfields of the request. Possible combinations:subject.type
subject.id
userAccount<user_ID>serviceAccount<service_account_ID>federatedUser<user_ID>group<group_ID>systemallAuthenticatedUsers(
All authenticated usersgroup)allUsers(
All usersgroup)group:organization:<organization_ID>:users(
All users in organization Xgroup)group:federation:<federation_ID>:users(
All users in federation Ngroup)group:userpool:<pool_ID>:users(
All users in userpool Pgroup)
To learn how to assign a role for the respective resource, see:
Assigning a role for an organization
-
Log in to Yandex Identity Hub
using an administrator or organization owner account. -
In the left-hand panel, select
Access bindings. -
At the top right, click Assign roles.
-
Go to the Groups tab and select the group you need or search by group name.
You can also assign a role to one of the system groups:
All users in organization X: The group includes all users in organizationX.All users in federation N: The group includes all users in federationN.
-
Click
Add role and select the role for the organization you want to assign to the group. You can assign multiple roles. -
Click Save.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
-
Assign a role for an organization to a group:
yc organization-manager organization add-access-binding \ --id <organization_ID> \ --role <role_ID> \ --subject group:<group_ID>Where:
-
--id: ID of the organization you are assigning a role for. -
--role: ID of the role you need to assign. -
--subject: Subject getting the role.Subject designations
To indicate a subject, use the
--subjectparameter in<subject_type>:<ID>format. For some subject types, the Yandex Cloud CLI provides separate parameters instead of--subject, where you only need to specify the subject name or ID without the type. Possible subject designations and the corresponding CLI parameters:Subject type
Subject designation
Yandex Cloud CLI parameter
userAccountuserAccount:<user_ID>--user-account-idor--user-yandex-loginserviceAccountserviceAccount:<service_account_ID>--service-account-idor--service-account-namefederatedUserfederatedUser:<user_ID>--user-account-idgroupgroup:<group_ID>--group-memberssystemsystem:allAuthenticatedUsers(
All authenticated usersgroup)--all-authenticated-userssystem:allUsers(
All usersgroup)—
system:group:organization:<organization_ID>:users(
All users in organization Xgroup)--organization-userssystem:group:federation:<federation_ID>:users(
All users in federation Ngroup)--federation-userssystem:group:userpool:<pool_ID>:users(
All users in userpool Pgroup)—
-
-
Make sure the requested permissions are granted:
yc organization-manager organization list-access-bindings <organization_ID>A response contains a list of all roles assigned to users and groups in the organization:
+------------------------------------------+--------------+----------------------+ | ROLE ID | SUBJECT TYPE | SUBJECT ID | +------------------------------------------+--------------+----------------------+ | organization-manager.admin | userAccount | ajev1p2345lj******** | | organization-manager.organizations.owner | userAccount | ajev1p2345lj******** | | editor | group | ajev1p2345lj******** | | viewer | group | ajev1p2345lj******** | +------------------------------------------+--------------+----------------------+
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), authenticate using the appropriate method.
-
Add the resource parameters to the configuration file and specify the required role and group:
resource "yandex_organizationmanager_organization_iam_member" "users-editors" { organization_id = "<organization_ID>" role = "<role_ID>" member = "group:<group_ID>" }Where:
-
organization_id: Organization ID. This is a required setting. -
role: Role being assigned. This is a required setting. -
member: Subject getting the role. This is a required setting.Subject designations
To indicate a subject, use a combination of its type and unique ID, i.e.,
<subject_type>:<ID>. How you can designate a subject:Subject type
Subject designation
userAccountuserAccount:<user_ID>serviceAccountserviceAccount:<service_account_ID>federatedUserfederatedUser:<user_ID>groupgroup:<group_ID>systemsystem:allAuthenticatedUsers(
All authenticated usersgroup)system:allUsers(
All usersgroup)system:group:organization:<organization_ID>:users(
All users in organization Xgroup)system:group:federation:<federation_ID>:users(
All users in federation Ngroup)system:group:userpool:<pool_ID>:users(
All users in userpool Pgroup)
For more on the properties of the
yandex_organizationmanager_organization_iam_memberresource, see this provider guide. -
-
Create the resources:
-
In the terminal, navigate to the configuration file directory.
-
Make sure the configuration is correct using this command:
terraform validateIf the configuration is valid, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
-
Apply the configuration changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
With this done, the specified access permissions will be assigned. You can check the role assignment using the Cloud Center UI
or this CLI command:yc organization-manager organization list-access-bindings <organization_ID> -
To assign a role for an organization to a user group, use the updateAccessBindings REST API method for the Organization resource or the OrganizationService/UpdateAccessBindings gRPC API call and provide the following in the request:
-
ADDvalue in theaccessBindingDeltas[].actionparameter to add a role. -
Role in the
accessBindingDeltas[].accessBinding.roleIdparameter. -
ID of the subject getting the role in the
accessBindingDeltas[].accessBinding.subject.idparameter. -
Type of the subject getting the role in the
accessBindingDeltas[].accessBinding.subject.typeparameter.Subject designations
To indicate a subject, use a combination of its type and unique ID in the
subject.typeandsubject.idfields of the request. Possible combinations:subject.type
subject.id
userAccount<user_ID>serviceAccount<service_account_ID>federatedUser<user_ID>group<group_ID>systemallAuthenticatedUsers(
All authenticated usersgroup)allUsers(
All usersgroup)group:organization:<organization_ID>:users(
All users in organization Xgroup)group:federation:<federation_ID>:users(
All users in federation Ngroup)group:userpool:<pool_ID>:users(
All users in userpool Pgroup)