Revoking a role for a resource
You can prevent a subject from accessing a resource. To do this, revoke the subject's roles for that resource and any resources from which permissions are inherited. For more information, see How access management works in Yandex Cloud.
- In the management console
, select the folder where you want to revoke a role for a resource. - Navigate
to Container Registry. - Select a registry or repository in it.
- Navigate to the Access bindings tab.
- Select a user from the list and click
next to the username. - Click Edit roles.
- Click
next to the role to revoke. - 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.
-
View assigned roles:
yc container <resource> list-access-bindings <resource_name_or_ID>Where:
<resource>:registryorrepositoryresource type.<resource_name_or_ID>: Name or ID of the resource the role is assigned for.
-
Revoke a role:
-
From a user:
yc container <resource> remove-access-binding <resource_name_or_ID> \ --role <role> \ --user-account-id <user_ID> -
yc container <resource> remove-access-binding <resource_name_or_ID> \ --role <role> \ --service-account-id <service_account_ID> -
From all authenticated users (the
All authenticated userspublic group):yc container <resource> remove-access-binding <resource_name_or_ID> \ --role <role> \ --all-authenticated-usersWhere:
<resource>:registryorrepositoryresource type.<resource_name_or_ID>: Name or ID of the resource you want to revoke the role for.<role_ID>: Role you want to revoke.
Example
The example below revokes the
container-registry.adminrole formy-first-registryfrom the user.yc container registry remove-access-binding my-first-registry \ --role container-registry.admin \ --user-account-id ajeugsk5ubk6********Result:
done (9s) -
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.
-
Open the Terraform configuration file and delete the section describing the role assignment.
Example of role assignment description in the Terraform configuration:
resource "yandex_container_registry_iam_binding" "registry_name" { registry_id = "<registry_ID>" role = "<role>" members = [ "userAccount:<user_ID>", ] }For more information about
yandex_container_registry_iam_binding, 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 whether the role has been revoked 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>
View the roles assigned for resources.
To revoke roles assigned for a registry, use the updateAccessBindings REST API method for the Registry resource or the RegistryService/UpdateAccessBindings gRPC API call.
To revoke roles assigned for a repository, use the updateAccessBindings REST API method for the Repository resource or the RepositoryService/UpdateAccessBindings gRPC API call.
For more information about managing roles, see this Yandex Identity and Access Management guide.