Revoke a role for a resource
If you wish to deny a subject access to a resource, revoke the relevant roles for this resource and for resources that grant inherited access rights. For more information, see How access management works in Yandex Cloud.
Note
If you need to temporarily revoke all access rights from a user with a Yandex account, you can revoke just the resource-manager.clouds.member
role. Although the user keeps all the other roles, they can't perform any operations with the cloud resources. When you add the user to the cloud again, the access rights will already be configured.
Revoking a role
In the management console, you can only revoke a cloud or folder role:
-
To revoke a role only in the folder:
- Open the folder page. You can select a folder on the home page of the management console. This page displays folders for the selected cloud.
- Go to Access bindings in folder (the Access bindings button in the left panel).
- Select the appropriate user in the list and click next to the user's name.
- Click Edit roles.
- Click next to the role you wish to revoke.
- Click Save.
-
To revoke a role in the cloud:
- Select the desired cloud.
- Go to Access bindings in cloud (the Access bindings button in the left panel).
- Select the appropriate user in the list and click next to the user's name.
- If you want to revoke all of the user's roles in the cloud, click Revoke roles.
- If you want to revoke an individual user's roles in the cloud:
- Click Edit roles.
- In the Configure access rights window, click next to each role you want to revoke.
- Click Save.
If you don't have the Yandex Cloud command line interface yet, install and initialize it.
To revoke a role from a subject, delete the corresponding access binding for the appropriate resource:
-
View roles and their assignees:
View the roles assigned for a resource:
yc <service-name> <resource> list-access-bindings <resource-name>|<resource-id>
Where:
<service-name>
: The name of the service that the resource belongs to (for example,resource-manager
).<resource>
: The resource category, such asfolder
.<resource-name>
: The name of the resource. You can specify a resource by its name or ID.<resource-id>
: The resource ID.
For example, you can view what roles were assigned for the
default
folder and to whom:yc resource-manager folder list-access-bindings default
Result:
+---------------------+----------------+----------------------+ | ROLE ID | SUBJECT TYPE | SUBJECT ID | +---------------------+----------------+----------------------+ | editor | serviceAccount | ajepg0mjas06siuj5usm | | viewer | userAccount | aje6o61dvog2h6g9a33s | +---------------------+----------------+----------------------+
-
To delete an access binding, run:
yc <service-name> <resource> remove-access-binding <resource-name>|<resource-id> \ --role <role-id> \ --subject <subject-type>:<subject-id>
Where:
<role-id>
: The ID of the role to revoke (such asresource-manager.clouds.owner
).<subject-type>
: The subject type to revoke a role from.<subject-id>
: The subject ID.
To revoke a resource role from a subject, delete the corresponding access binding:
-
View what roles were assigned for resources and to whom using the
listAccessBindings
method. For example, to view the roles for the folderb1gvmob95yysaplct532
:export FOLDER_ID=b1gvmob95yysaplct532 export IAM_TOKEN=CggaATEVAgA... curl -H "Authorization: Bearer ${IAM_TOKEN}" "https://resource-manager.api.cloud.yandex.net/resource-manager/v1/folders/${FOLDER_ID}:listAccessBindings"
Result:
{ "accessBindings": [ { "subject": { "id": "ajei8n54hmfhuk5nog0g", "type": "userAccount" }, "roleId": "editor" } ] }
-
Create a request body, for example, in a
body.json
file. In the request body, specify which access binding to delete. For example, revoke theeditor
role from userajei8n54hmfhuk5nog0g
:body.json:
{ "accessBindingDeltas": [{ "action": "REMOVE", "accessBinding": { "roleId": "editor", "subject": { "id": "ajei8n54hmfhuk5nog0g", "type": "userAccount" } } } ] }
-
Revoke the role by deleting the specified access binding:
export FOLDER_ID=b1gvmob95yysaplct532 export IAM_TOKEN=CggaATEVAgA... curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${IAM_TOKEN}" \ -d '@body.json' \ "https://resource-manager.api.cloud.yandex.net/resource-manager/v1/folders/${FOLDER_ID}:updateAccessBindings"