Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Container Registry
  • Getting started
    • All guides
    • Installing and configuring Docker
    • Authentication in Container Registry
    • Scanning Docker images for vulnerabilities
    • Creating a trigger for a registry
      • Assigning a role
      • Viewing assigned roles
      • Revoking a role
  • Yandex Container Solution
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Troubleshooting
  • FAQ
  1. Step-by-step guides
  2. Working with roles
  3. Assigning a role

Assigning a role for a resource

Written by
Yandex Cloud
Updated at May 29, 2025

To grant access to a resource, assign the subject a role for the resource itself or a resource from which access permissions are inherited, e.g., a folder or cloud. For the current list of resources you can assign roles for, see Which resources you can assign a role for.

Management console
CLI
Terraform
API
  1. In the management console, select the folder where you want to assign a role for a resource.
  2. In the list of services, select Container Registry.
  3. Select a registry or repository in it.
  4. Go to the Access bindings tab.
  5. Click Assign roles.
  6. In the window that opens, select a group, user, or service account.
  7. Click Add role and select the role from the list.
  8. Click Save.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.

To assign a role for a resource, run the following command:

  • To a user:

    yc container <resource> add-access-binding <resource_name_or_ID> \
      --role <role> \
      --user-account-id <user_ID>
    
  • To a service account:

    yc container <resource> add-access-binding <resource_name_or_ID> \
      --role <role> \
      --service-account-id <service_account_ID>
    
  • To all authenticated users (the All authenticated users public group):

    yc container <resource> add-access-binding <resource_name_or_ID> \
      --role <role> \
      --all-authenticated-users
    

    Where:

    • <resource>: registry or repository resource type.
    • <resource_name_or_ID>: Name or ID of the resource to assign the role for.
    • <role>: Role you want to assign.

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 \
  --user-account-id ajeugsk5ubk6********

Result:

done (4s)

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

  1. Describe the following in a configuration file:

    • The yandex_container_registry_iam_binding resource parameters to assign the role for the registry:

      resource "yandex_container_registry_iam_binding" "registry_name" {
        registry_id = "<registry_ID>"
        role        = "<role>"
      
        members = [
          "userAccount:<user_ID>",
        ]
      }
      

      Where:

      • registry_id: ID of the registry for which a 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: ID of the user, group, or service account to which you are assigning the role.
    • The yandex_container_repository_iam_binding resource parameters to assign the role for the repository:

      resource "yandex_container_repository_iam_binding" "repository_name" {
        repository_id = "<repository_ID>"
        role          = "<role>"
      
        members = [
          "serviceAccount:<service_account_ID>",
        ]
      }
      

      Where:

      • repository_id: ID of the repository for which you are assigning the role. To find out the ID of a repository, get a list of repositories in the folder.
      • role: Role you want to assign.
      • members: ID of the user, group, or service account to which you are assigning the role.

    For more information about yandex_container_repository_iam_binding, see the provider documentation.

    1. In the terminal, go to the folder where you edited the configuration file.

    2. Make sure the configuration file is correct using this command:

      terraform validate
      

      If the configuration is correct, you will get this message:

      Success! The configuration is valid.
      
    3. Run this command:

      terraform plan
      

      The terminal will display a list of resources with their properties. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.

    4. Apply the changes:

      terraform apply
      
    5. Type yes and press Enter to confirm the changes.

You can check that the role has been assigned using the management console or this CLI command:

  • Registry:

    yc container registry list-access-bindings <registry_name_or_ID>
    
  • Repository:

    yc container repository list-access-bindings <repository_name_or_ID>
    

Use the updateAccessBindings REST API method for the Registry resource or the RegistryService/UpdateAccessBindings gRPC API call.

Use the updateAccessBindings REST API method for the Repository resource or the RepositoryService/UpdateAccessBindings gRPC API call.

Was the article helpful?

Previous
Creating a trigger for a registry
Next
Viewing assigned roles
© 2025 Direct Cursus Technology L.L.C.