Assigning roles
To grant access to a resource, assign a role for it. You can assign a role to:
You can assign a role not only for the resource itself but also for its parent resource, as the former inherits access permissions from the latter. For example, if a service account gets a role for a cloud, it will also get permissions for all resources across the cloud's folders. For more information, see How access management works in Yandex Cloud.
To assign a role for a resource, you need the admin or service-name.admin role, where service-name is the name of the service to which the resource belongs.
Learn which resources you can assign a role for.
To select roles, look them up in the role reference.
Note
Even if an operation with resources pertaining to Yandex Cloud services is allowed by a role, it may still be blocked if the organization, cloud, or folder is subject to an access policy prohibiting this operation.
Assigning a role for a cloud
- In the management console
, click or in the top panel and select the cloud or folder. - Navigate to the Access bindings tab.
- Click Configure access.
- Select the group, user, or service account you need to grant access to a cloud or folder.
- Click
Add role and select the required 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.
To assign a role for a cloud or folder:
-
View the description of the CLI command for assigning roles:
yc resource-manager <cloud_or_folder> add-access-binding --helpSpecify
cloudfor a cloud orfolderfor a folder. -
Get a list of available clouds or folders with their IDs:
yc resource-manager <cloud_or_folder> list -
Get the ID of the user, service account, user group, organization, or identity federation to which or the users of which you are assigning a role.
-
To assign a role, run this command:
yc resource-manager <cloud_or_folder> add-access-binding \ --id <cloud_or_folder_ID> \ --role <role_ID> \ --subject <subject_type>:<subject_ID>Where:
-
--id: ID of the resource to assign the role for. -
--role: ID of the role you need to assign, 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, to assign a service account the
viewerrole for the folder:yc resource-manager folder add-access-binding \ --id b1g672qpemb4******** \ --role viewer \ --subject serviceAccount:aje8m5luj4qf******** -
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.
-
Describe the roles you are assigning in the configuration file:
Here is an example of the configuration file structure:
// Assigning a role for the cloud resource "yandex_resourcemanager_cloud_iam_member" "cloud_member" { cloud_id = "<cloud_ID>" role = "<role>" member = "<subject>" } // Assigning a role for the folder resource "yandex_resourcemanager_folder_iam_member" "folder_member" { folder_id = "<folder_ID>" role = "<role>" member = "<subject>" }Where:
-
cloud_id: Cloud ID. You can get a list of available clouds using the CLI command:yc resource-manager cloud list. This is a required setting. -
folder_id: Folder ID You can get the list of available folders using theyc resource-manager cloud listCLI command. This is a required setting. -
role: Role you need to assign. You can get a list of roles using the CLI command:yc iam role list. In one resource, only one role can be 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 Terraform resources, 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.
This will create the necessary resources in the organization.
-
To assign a role for a cloud, use the updateAccessBindings REST API method for the Cloud resource or the CloudService/UpdateAccessBindings gRPC API call.
To assign a role for a folder, 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)
Assigning a role for an organization
To grant access permissions for an organization, you need the organization-manager.admin role or higher. For more information on role sequence, see this Yandex Identity Hub document.
To assign 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. -
If the user, service account, or user group already has at least one role assigned, click
in the row with that user, service account, or group and select Assign roles.If the user, service account, or user group is not on the list, click Assign roles in the top-right corner. In the window that opens, select the user, service account, or group from the list. If required, use the search bar.
-
Click
Add role and select the role to assign. You can assign multiple roles.You can find the description of the available roles 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.
To assign a role for an organization:
-
View the description of the CLI command for assigning roles:
yc organization-manager organization add-access-binding --help -
Get a list of available organizations with their IDs:
yc organization-manager organization list -
Get the ID of the user, service account, user group, organization, or identity federation to which or the users of which you are assigning a role.
-
To assign a role, run this command:
yc organization-manager organization add-access-binding \ --id <organization_ID> \ --role <role_ID> \ --subject <subject_type>:<subject_ID>Where:
-
--id: ID of the resource to assign the role for. -
--role: ID of the role you need to assign, 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, to assign a service account the
viewerrole for the organization:yc organization-manager organization add-access-binding \ --id org672qpemb4******** \ --role viewer \ --subject serviceAccount:aje8m5luj4qf******** -
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.
To assign a role for an organization:
-
Get the ID of the user, service account, or user group you are assigning a role to.
-
Describe the resource with the role for the organization in the configuration file.
Here is an example of the configuration file structure:
resource "yandex_organizationmanager_organization_iam_binding" "<resource_name>" { organization_id = "<organization_ID>" role = "<role>" member = "<subject>" }Where:
-
organization_id: Organization ID. This is a required setting. -
role: Role. For each role, you can only use oneyandex_organizationmanager_organization_iam_bindingresource. 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 information, 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.
This will create the necessary resources in the organization. You can check the new resources using the management console
or this CLI command:yc organization-manager organization list-access-bindings <organization_name_or_ID> -
To assign a role for the organization, 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)
Assigning a role for a resource
You can assign a role not only for an organization, cloud, or folder but their child resources as well. These are listed in Resources that roles can be assigned for.
To assign a role for a resource:
- In the management console
, click or in the top panel and select the folder containing the resource. - Open its page.
- Navigate to
Access bindings and click Assign roles. - Select the group, user, or service account you need to grant access to a resource.
- Click
Add role and select the required 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.
To assign a role for a resource:
-
View the description of the CLI command for assigning roles:
yc <service_name> <resource> add-access-binding --helpExample for a Yandex Compute Cloud VM:
yc compute instance add-access-binding --help -
Get a list of resources with their IDs:
yc <service_name> <resource> list -
Get the ID of the user, service account, user group, organization, or identity federation to which or the users of which you are assigning a role.
-
To assign a role, run this command:
yc <service_name> <resource> add-access-binding \ --id <resource_ID> \ --role <role_ID> \ --subject <subject_type>:<subject_ID>Where:
-
--id: ID of the resource to assign the role for. -
--role: ID of the role you need to assign, 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, to assign a service account the
viewerrole for the VM:yc compute instance add-access-binding \ --id ins672qpemb4******** \ --role viewer \ --subject serviceAccount:aje8m5luj4qf******** -
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.
To assign a role for an organization:
-
Get the ID of the user, service account, or user group you are assigning a role to.
-
Describe the resource with the role for the organization in the configuration file.
Sample configuration file structure for assigning a role to a folder:
resource "yandex_resourcemanager_folder_iam_member" "admin-account-iam" { folder_id = "<folder_ID>" role = "<role>" member = "<subject>" }Where:
-
folder_id: Folder ID. This is a required setting. -
role: Role. For each role, you can only use oneyandex_organizationmanager_organization_iam_bindingresource. 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 information, 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.
This will create the necessary resources in the organization. You can check the new resources using the management console
or CLI commands. -
To assign a role for a resource, use the updateAccessBindings REST API method or gRPC API call for the resource 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)
Assigning multiple roles
- In the management console
, select the folder the resource resides in. - Open its page.
- Navigate to
Access bindings and click Assign roles. - Select the group, user, or service account you need to grant access to a resource.
- Click
Add role and select the required roles. - Click Save.
Alert
The set-access-bindings command for assigning multiple roles completely rewrites access permissions for the resource. All current resource roles will be deleted.
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.
To assign multiple roles for a resource:
-
Make sure the resource has no important roles assigned before proceeding:
yc <service_name> <resource> list-access-bindings \ --id <resource_ID>Example for a Yandex Compute Cloud VM:
yc compute instance list-access-bindings \ --id <VM_ID> -
View the description of the CLI command for assigning roles:
yc <service_name> <resource> set-access-bindings --help -
Get a list of resources with their IDs:
yc <service_name> <resource> list -
Get the ID of the user, service account, user group, organization, or identity federation to which or the users of which you are assigning a role.
-
To assign a role, run this command:
yc <service_name> <resource> set-access-bindings \ --id <resource_ID> \ --access-binding role=<role>,subject=<subject_type>:<subject_ID>Where:
-
--id: ID of the resource to assign the role for. -
role: ID of the role you need to assign, 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)—
Provide a separate
--access-bindingparameter for each role. For example, to assign a service account multiple roles for a VM:yc compute instance set-access-bindings \ --id ins672qpemb4******** \ --access-binding role=compute.disks.user,subject=<subject_type>:aje8m5luj4qf******** \ --access-binding role=compute.images.user,subject=<subject_type>:aje8m5luj4qf******** \ --access-binding role=compute.operator,subject=<subject_type>:aje8m5luj4qf******** -
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.
-
Describe the roles you are assigning in the configuration file:
Sample configuration file structure for assigning multiple roles for a cloud:
resource "yandex_resourcemanager_cloud_iam_member" "cloud_member_1" { cloud_id = "<cloud_ID>" role = "<role_1>" members = ["<subject_1>","<subject_2>,...,<subject_n>"] } resource "yandex_resourcemanager_cloud_iam_member" "cloud_member_2" { cloud_id = "<cloud_ID>" role = "<role_2>" members = ["<subject_1>","<subject_2>,...,<subject_n>"] }Where:
-
cloud_id: Cloud ID. You can get a list of available clouds using the CLI command:yc resource-manager cloud list. This is a required setting. -
role: Role you need to assign. You can get a list of roles using the CLI command:yc iam role list. In oneyandex_resourcemanager_cloud_iam_memberresource, only one role can be assigned. This is a required setting. -
members: Designations of subjects 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 Terraform resources, 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.
This will create the necessary resources in the organization.
-
Alert
The setAccessBindings method for assigning multiple roles completely rewrites access permissions for the resource. All current resource roles will be deleted.
To assign multiple roles for a resource, use the setAccessBindings REST API method or gRPC API call for the resource. In your request, provide an array of objects, each one matching a particular role and containing the following data:
-
Role in the
accessBindings[].roleIdparameter. -
ID of the subject getting the roles in the
accessBindings[].subject.idparameter. -
Type of the subject getting the roles in the
accessBindings[].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)