Assigning roles for a trail
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.
-
See the description of the CLI command for assigning roles for a trail:
yc audit-trails trail set-access-bindings --help -
Get a list of trails:
yc audit-trails trail listResult:
+----------------------+--------------+--------+-------------------+ | ID | NAME | STATUS | FILTERS | +----------------------+--------------+--------+-------------------+ | cnp82sb0phnm******** | trailfromapi | ACTIVE | storage compute | | | | | management.events | | cnp8v52idttr******** | tf-trail | ACTIVE | storage compute | | | | | mdb.postgresql | | cnpnkcubr529******** | test-2 | ACTIVE | compute | +----------------------+--------------+--------+-------------------+ -
Run the following command to assign a role for a trail:
yc audit-trails trail set-access-bindings \ --id <trail_ID> \ --access-binding role=<role>,subject=<subject_type>:<subject_ID>Where:
-
--id: ID of the digital signature key pair. -
Where
--access-bindingis the role and the subject the role is assigned to.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)—
Provide a separate
--access-bindingparameter for each role. Here is an example:yc audit-trails trail set-access-bindings \ --id <trail_ID> \ --access-binding role=<role1>,subject=<subject_type>:<subject_ID> \ --access-binding role=<role2>,subject=<subject_type>:<subject_ID> \ --access-binding role=<role3>,subject=<subject_type>:<subject_ID> -
To assign roles for a trail, use the setAccessBindings REST API method for the Trail resource or the TrailService/SetAccessBindings gRPC API call. In your request, provide an array of objects, each one matching a particular role and containing the following data:
-
Role in the
access_bindings[].role_idparameter. -
ID of the subject getting the roles in the
access_bindings[].subject.idparameter. -
Type of the subject getting the roles in the
access_bindings[].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. Here are 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)