Assigning a role for a resource
Warning
Starting October 13, 2026, Yandex Container Registry will be unavailable to new users.
The existing users can create resources until November 10, 2026. Afterwards, Yandex Container Registry will go read-only and cease to operate on December 14, 2026. For more information on how it will be handled, see this article on Yandex Container Registry sunset.
To grant access to a resource, assign a role to a subject for the resource itself or for a resource from which access permissions are inherited, such as a folder or cloud. For the current list of resources you can assign roles for, see Resources you can assign a role for.
- In the management console
, select the folder where you want to assign a role for a resource. - Navigate
to Container Registry. - Select a registry or repository in it.
- Navigate to the Access bindings tab.
- Click Assign roles.
- In the window that opens, select a group, user, or service account.
- Click
Add role and select role from the list. - 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.
Run this command to assign a role for a resource:
yc container <resource> add-access-binding <resource_name_or_ID> \
--role <role> \
--subject <subject_type>:<subject_ID>
Where:
-
<resource>:registryorrepositoryresource type. -
<resource_name_or_ID>: Name or ID of the resource to assign the role for. -
--role: Role you want 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 matching 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)—
Example
In the example below, we are assigning the container-registry.admin role for my-first-registry to a user.
yc container registry add-access-binding my-first-registry \
--role container-registry.admin \
--subject userAccount:ajeugsk5ubk6********
Result:
done (4s)
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 following in the configuration file:
-
The
yandex_container_registry_iam_bindingresource parameters to assign the role for the registry:resource "yandex_container_registry_iam_binding" "registry_name" { registry_id = "<registry_ID>" role = "<role>" members = [ "<subject_type>:<subject_ID>", ] }Where:
-
registry_id: ID of the registry for which the role is being assigned. To find out the registry ID, get a list of registries in the folder. -
role: Role you want to assign. -
members: List of designations of subjects the role is assigned to.Subject designations
To indicate a subject, use a combination of its type and unique ID, i.e.,
<subject_type>:<ID>. Here is 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)
-
-
The
yandex_container_repository_iam_bindingresource parameters to assign the role for the repository:resource "yandex_container_repository_iam_binding" "repository_name" { repository_id = "<repository_ID>" role = "<role>" members = [ "<subject_type>:<subject_ID>", ] }Where:
-
repository_id: ID of the repository for which you are assigning the role. To find out the repository ID, get a list of repositories in the folder. -
role: Role you want to assign. -
members: List of designations of subjects getting the role.Subject designations
To indicate a subject, use a combination of its type and unique ID, i.e.,
<subject_type>:<ID>. Here is 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_container_repository_iam_bindingresource, see this provider guide. -
-
-
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.
-
You can check the role assignment using the management console
-
Registry:
yc container registry list-access-bindings <registry_name_or_ID> -
Repository:
yc container repository list-access-bindings <repository_name_or_ID>
To assign a role for a registry, use the updateAccessBindings REST API method for the Registry resource or the RegistryService/UpdateAccessBindings gRPC API call.
To assign a role for a repository, use the updateAccessBindings REST API method for the Repository resource or the RepositoryService/UpdateAccessBindings gRPC API call.
In the request body, set the action property to ADD and specify subject type and ID in the subject property.
Subject designations
To indicate a subject, use a combination of its type and unique ID in the subject.type and subject.id fields of the request. Here are possible combinations:
|
subject.type |
subject.id |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
( |
|
( |
|
|
( |
|
|
( |
|
|
( |