Assigning a role to a user
Organization administrators and owners can assign roles in Yandex Identity Hub. You can assign to users not just organization management roles but also roles for access to your organization's connected cloud resources.
For information on roles available in Yandex Cloud and their associated permissions, please review the Yandex Identity and Access Management documentation, Role reference Yandex Cloud.
-
Log in to Yandex Identity Hub
with an administrator or organization owner account. -
In the left-hand panel, select
Access bindings. -
If the user already has at least one role, click
and select Assign roles in the row with this user.If the user is not on the list, click Assign roles in the top-right corner. In the window that opens, select a user from the list or use the search bar.
-
Click
Add role and select the role you want to assign to the user. You can assign multiple roles.You can find the description of the available roles in the Yandex Identity and Access Management documentation in the Yandex Cloud role reference.
-
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.
-
Select the role you want to assign.
-
Get the user ID.
-
Assign a role using this command:
yc organization-manager organization add-access-binding <organization_name_or_ID> \ --role <role_ID> \ --user-account-id <user_ID>Where:
--role: Role ID.--user-account-id: User ID. You can also use the--user-yandex-loginparameter and specify the username instead of the ID.
For example, assign a user the administrator role for an organization with the
b1gmit33ngp3********ID:yc organization-manager organization add-access-binding b1gmit33ngp3******** \ --role resource-manager.admin \ --user-account-id 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.
-
Select the role you want to assign.
-
Get the user ID.
-
Describe the roles you are assigning in the configuration file:
Example of configuration file structure for assigning a role for an organization:
resource "yandex_organizationmanager_organization_iam_binding" "editor" { organization_id = "<organization_ID>" role = "<role_ID>" member = "userAccount:<user_ID>" }Where:
-
organization_id: Organization ID. -
role: Role you want to assign. For each role, you can only use oneyandex_organizationmanager_organization_iam_bindingresource. -
member: Subject getting the role.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_bindingresource, 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.
-
The specified user will then get roles in the organization. You can check the role assignment using the Cloud Center UI
To assign the user a role for the organization, use the updateAccessBindings REST API method for the Organization resource or the OrganizationService/UpdateAccessBindings gRPC API call.
-
Select the role you want to assign.
-
Get the user ID.
-
Create the request body, e.g., in the
body.jsonfile. In theactionproperty, enterADDand specify theuserAccountorfederatedUsertype and user ID undersubject.body.json:
{ "accessBindingDeltas": [{ "action": "ADD", "accessBinding": { "roleId": "<role_ID>", "subject": { "id": "<user_ID>", "type": "userAccount" } } }] }Where:
-
ADDin theaccessBindingDeltas[].actionparameter indicates you need to add a role. -
accessBindingDeltas[].accessBinding.roleId: ID of the role you need to assign. -
accessBindingDeltas[].accessBinding.subject.id: ID of the subject the role is assigned to. -
accessBindingDeltas[].accessBinding.subject.type: Type of subject the role is assigned to.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)
-
-
Assign the role. For example, for an organization with the
bpf3crucp1v2********ID:export ORGANIZATION_ID=bpf3crucp1v2******** export IAM_TOKEN=<IAM_token> curl \ --request POST \ --header "Content-Type: application/json" \ --header "Authorization: Bearer ${IAM_TOKEN}" \ --data '@body.json' \ "https://organization-manager.api.cloud.yandex.net/organization-manager/v1/organizations/${ORGANIZATION_ID}:updateAccessBindings"
In a similar way, you can assign roles for an organization to a service account.