[Yandex Cloud documentation](../../index.md) > [Yandex Key Management Service](../index.md) > Access management

# Access management in Key Management Service

In this section, you will learn about:
* [Resources you can assign a role for](#resources).
* [Roles this service has](#roles-list).
* [Roles required](#choosing-roles) for specific actions.

## Access management {#about-access-control}

[Yandex Identity and Access Management](../../iam/index.md) checks all operations in Yandex Cloud. If an entity does not have required permissions, IAM returns an error.


To grant permissions for a resource, [assign](../../iam/operations/roles/grant.md) the relevant resource roles to an entity performing operations. You can assign roles to a [Yandex account](../../iam/concepts/users/accounts.md#passport), [service account](../../iam/concepts/users/service-accounts.md), [local user](../../iam/concepts/users/accounts.md#local), [federated user](../../iam/concepts/federations.md), [user group](../../organization/operations/manage-groups.md), [system group](../../iam/concepts/access-control/system-group.md), or [public group](../../iam/concepts/access-control/public-group.md). For more information, see [How access management works in Yandex Cloud](../../iam/concepts/access-control/index.md).

To assign a role for a resource, a user should have the `kms.admin` role or one of the following roles for that resource:

* `admin`
* `resource-manager.admin`
* `organization-manager.admin`
* `resource-manager.clouds.owner`
* `organization-manager.organizations.owner`

## Resources you can assign a role for {#resources}

You can assign a role to an [organization](../../organization/concepts/organization.md), [cloud](../../resource-manager/concepts/resources-hierarchy.md#cloud), or [folder](../../resource-manager/concepts/resources-hierarchy.md#folder). The roles assigned to organizations, clouds, and folders also apply to their nested resources.

You can assign a role for individual resources within the service in the [management console](https://console.yandex.cloud), using the Yandex Cloud [CLI](../../cli/cli-ref/kms/cli-ref/index.md), [API](../api-ref/authentication.md), or [Terraform](../../terraform/index.md):

# Key Management Service resources for which you can assign roles

* [Symmetric encryption key](../operations/key-access.md)
* [Asymmetric encryption key pair](../operations/asymmetric-encryption-key-access.md)
* [Asymmetric digital signature key pair](../operations/asymmetric-signature-key-access.md)

## Roles this service has {#roles-list}

You can manage access to KMS keys using both service and primitive roles.

The chart below shows service’s roles and their permission inheritance. For example, `editor` inherits all `viewer` permissions. You can find role descriptions below the chart.

```mermaid
%%{
  init: {
    "flowchart": { "defaultRenderer": "elk" },
    "elk": { "nodePlacementStrategy": "LINEAR_SEGMENTS" }
  }
}%%
flowchart BT
    kms.auditor --> kms.viewer
    kms.viewer --> kms.editor
    kms.editor --> kms.admin
    kms.keys.encrypter["`kms.keys
    encrypter`"] --> kms.keys.encrypterDecrypter
    kms.keys.decrypter["`kms.keys
    decrypter`"] --> kms.keys.encrypterDecrypter
    kms.keys.user["`kms.keys
    user`"] --> kms.keys.encrypterDecrypter
    kms.keys.encrypterDecrypter --> kms.editor
    kms.asymmetricEncryptionKeys.decrypter["`kms.asymmetric
    EncryptionKeys.
    decrypter`"] --> kms.editor

    kms.asymmetricEncryptionKeys.publicKeyViewer["`kms.asymmetric
    EncryptionKeys.
    publicKeyViewer`"] --> kms.editor
    kms.asymmetricSignatureKeys.publicKeyViewer["`kms.asymmetric
    SignatureKeys.
    publicKeyViewer`"] --> kms.editor
    kms.asymmetricSignatureKeys.signer["`kms.asymmetric
    SignatureKeys.
    signer`"] --> kms.editor
```

### Service roles {#service-roles}

Service roles provide more granular control over KMS keys with KMS specifics in mind: subjects are strictly separated into key administrators (the `kms.admin` role) and users (the `kms.keys.encrypterDecrypter` role).

Users without the `resource-manager.clouds.owner` or `admin` role cannot assign roles via the management console.

#### kms.keys.user {#kms-keys-user}

The `kms.keys.user` role enables viewing the list of [symmetric encryption keys](../concepts/key.md) and information on them, as well as using such keys.

#### kms.keys.encrypter {#kms-keys-encrypter}

The `kms.keys.encrypter` role enables viewing info on [symmetric encryption keys](../concepts/key.md) and using such keys to encrypt data.

#### kms.keys.decrypter {#kms-keys-decrypter}

The `kms.keys.decrypter` role enables viewing info on [symmetric encryption keys](../concepts/key.md) and using such keys to decrypt data.

#### kms.keys.encrypterDecrypter {#kms-keys-encrypterDecrypter}

The `kms.keys.encrypterDecrypter` role enables viewing info on [symmetric encryption keys](../concepts/key.md) and using such keys to encrypt or decrypt data.

This role includes the `kms.keys.encrypter` and `kms.keys.decrypter` permissions.

#### kms.asymmetricEncryptionKeys.publicKeyViewer {#kms-asymmetricEncryptionKeys-publicKeyViewer}

The `kms.asymmetricEncryptionKeys.publicKeyViewer` role enables viewing info on [asymmetric encryption key pairs](../concepts/asymmetric-encryption-key.md), as well as getting a [public key](../concepts/asymmetric-encryption.md#acquire-public-key) from an encryption key pair.

#### kms.asymmetricSignatureKeys.publicKeyViewer {#kms-asymmetricSignatureKeys-publicKeyViewer}

The `kms.asymmetricSignatureKeys.publicKeyViewer` role enables viewing info on [digital signature key pairs](../concepts/asymmetric-signature-key.md), as well as getting a public key from a digital signature key pair.

#### kms.asymmetricSignatureKeys.signer {#kms-asymmetricSignatureKeys-signer}

The `kms.asymmetricSignatureKeys.signer` role enables signing data with a private key from a [digital signature key pair](../concepts/asymmetric-signature-key.md).

#### kms.asymmetricEncryptionKeys.decrypter {#kms-asymmetricEncryptionKeys-decrypter}

The `kms.asymmetricEncryptionKeys.decrypter` role enables decrypting data with a private key from an [asymmetric encryption key pair](../concepts/asymmetric-encryption-key.md).

#### kms.auditor {#kms-auditor}

The `kms.auditor` role enables viewing info on encryption keys and key pairs and access permissions assigned to them.

Users with this role can:
* View the list of [symmetric](../concepts/key.md) encryption keys, info on them and on [access permissions](../../iam/concepts/access-control/index.md) assigned to them.
* View info on [asymmetric encryption key pairs](../concepts/asymmetric-encryption-key.md) and access permissions assigned to them.
* View information on [digital signature key pairs](../concepts/asymmetric-signature-key.md) and on access permissions assigned to them.
* View details on the Key Management Service [quotas](../concepts/limits.md#kms-quotas).

#### kms.viewer {#kms-viewer}

The `kms.viewer` role enables viewing info on encryption and digital signature keys and key pairs, access permissions assigned to them, and KMS quotas.

Users with this role can:
* View the list of [symmetric](../concepts/key.md) encryption keys, info on them and on [access permissions](../../iam/concepts/access-control/index.md) assigned to them.
* View info on [asymmetric encryption key pairs](../concepts/asymmetric-encryption-key.md) and access permissions assigned to them.
* View information on [digital signature key pairs](../concepts/asymmetric-signature-key.md) and on access permissions assigned to them.
* View details on the Key Management Service [quotas](../concepts/limits.md#kms-quotas).

This role includes the `kms.auditor` permissions.

#### kms.editor {#kms-editor}

The `kms.editor` role allows you to create encryption and digital signature keys and key pairs as well as use them to encrypt, decrypt, and sign data.

Users with this role can:
* View the list of [symmetric](../concepts/key.md) encryption keys, info on them and their [access permissions](../../iam/concepts/access-control/index.md), as well as create, rotate, and modify symmetric key metadata, including rotation periods.
* Encrypt and decrypt data using symmetric encryption keys.
* View info on [asymmetric encryption key pairs](../concepts/asymmetric-encryption-key.md) and access permissions assigned to them as well as create such key pairs or modify their metadata.
* Get a [public key](../concepts/asymmetric-encryption.md#acquire-public-key) and decrypt data using a private key from an asymmetric encryption key pair.
* View info on [digital signature key pairs](../concepts/asymmetric-signature-key.md) and access permissions assigned to them as well as create such key pairs or modify their metadata.
* Get a public key and sign data using a private key from a digital signature key pair.
* View details on the Key Management Service [quotas](../concepts/limits.md#kms-quotas).

#### kms.admin {#kms-admin}

The `kms.admin` role enables managing encryption and digital signature keys and key pairs, as well as managing access to such keys or key pairs and using them to encrypt, decrypt, and sign data.

Users with this role can:
* View info on [access permissions](../../iam/concepts/access-control/index.md) assigned to [symmetric encryption keys](../concepts/key.md) and modify such permissions.
* View the list of symmetric encryption keys and details on them, as well as create, activate, deactivate, rotate, and delete symmetric encryption keys, or change their default version and metadata (including rotation period).
* Encrypt and decrypt data using symmetric encryption keys.
* View info on access permissions assigned to [asymmetric encryption key pairs](../concepts/asymmetric-encryption-key.md) and modify such permissions.
* View details on asymmetric encryption key pairs as well as create, activate, deactivate, and delete such key pairs, or modify their metadata.
* Get a [public key](../concepts/asymmetric-encryption.md#acquire-public-key) and decrypt data using a private key from an asymmetric encryption key pair.
* View info on access permissions assigned to [digital signature key pairs](../concepts/asymmetric-signature-key.md) and modify such permissions.
* View details on digital signature key pairs as well as create, activate, deactivate, and delete such key pairs, or modify their metadata.
* Get a public key and sign data using a private key from a digital signature key pair.
* View details on Key Management Service [quotas](../concepts/limits.md#kms-quotas).
* View info on the relevant [folder](../../resource-manager/concepts/resources-hierarchy.md#folder).

This role includes the `kms.editor` permissions.

### Primitive roles {#primitive-roles}

Primitive roles allow users to perform actions in all Yandex Cloud [services](../../overview/concepts/services.md).

#### auditor {#auditor}

The `auditor` role grants a permission to read configuration and metadata of any Yandex Cloud resources without any access to data.

For instance, users with this role can:
* View info on a [resource](../../resource-manager/concepts/resources-hierarchy.md).
* View the resource metadata.
* View the list of operations with a resource.

`auditor` is the most secure role that does not grant any access to the [service](../../overview/concepts/services.md) data. This role suits the users who need minimum access to the Yandex Cloud resources.

#### viewer {#viewer}

The `viewer` role grants the permissions to read the info on any Yandex Cloud [resources](../../resource-manager/concepts/resources-hierarchy.md).

This role includes the `auditor` permissions.

Unlike `auditor`, the `viewer` role provides access to [service](../../overview/concepts/services.md) data in read mode.

#### editor {#editor}

The `editor` role provides permissions to manage any Yandex Cloud [resources](../../resource-manager/concepts/resources-hierarchy.md), except for assigning roles to other users, transferring [organization](../../organization/concepts/organization.md) ownership, removing an organization, and deleting Key Management Service [encryption keys](../concepts/index.md).

For instance, users with this role can create, modify, and delete resources.

This role includes the `viewer` permissions.

#### admin {#admin}

The `admin` role enables assigning any roles, except for `resource-manager.clouds.owner` and `organization-manager.organizations.owner`, and provides permissions to manage any Yandex Cloud [resources](../../resource-manager/concepts/resources-hierarchy.md) (except for transferring [organization](../../organization/concepts/organization.md) ownership and removing an organization).

Prior to assigning the `admin` role for an organization, [cloud](../../resource-manager/concepts/resources-hierarchy.md#cloud), or [billing account](../../billing/concepts/billing-account.md), make sure to check out the information on protecting [privileged accounts](../../security/standard/all.md#privileged-users).

This role includes the `editor` permissions.

Instead of primitive roles, we recommend using service roles with more granular access control, allowing you to implement the [least privilege principle](../../security/standard/all.md#min-privileges).

For more information on primitive roles, see the [Yandex Cloud role reference](../../iam/roles-reference.md#primitive-roles).

## What roles do I need {#choosing-roles}

**Example of key access control**

We recommend working with roles as follows:
1. The cloud owner (the `resource-manager.clouds.owner` role) or administrator (the `admin` role) assigns the `kms.admin` role to the KMS administrator. 
1. The KMS administrator creates the required number of keys and assigns (through the CLI or API) roles for them: subjects from different teams get the `kms.keys.encrypter`, `kms.keys.decrypter`, `kms.asymmetricEncryptionKeys.publicKeyViewer`, `kms.asymmetricEncryptionKeys.decrypter`, and `kms.editor` roles for keys and folders.

It is good practice to store KMS keys in a dedicated folder apart from other Yandex Cloud resources.

Action | Methods | Required roles
----- | ----- | -----
**KMS** | | 
Getting information about keys and versions | `get`, `listVersions` | `kms.viewer` for the folder key
[Symmetric encryption and decryption](../api-ref/SymmetricCrypto/index.md) operations | `encrypt`, `decrypt`, `reEncrypt`, `generateDataKey` | `kms.keys.encrypterDecrypter` for the key (encryption and decryption), `kms.keys.encrypter` for the key (encryption only), and `kms.keys.decrypter` for the key (decryption only)
Getting a list of keys in the folder | `list` | `kms.auditor` for the folder
Getting a public key of an asymmetric encryption key pair | | `kms.asymmetricEncryptionKeys.publicKeyViewer` for the key
Decrypting data with a private key of an asymmetric encryption key pair | | `kms.asymmetricEncryptionKeys.decrypter` for the key
[Creating](../operations/key.md#create) and [updating](../operations/key.md#update) a key | `create`, `update` | `kms.editor` for the folder
[Rotating a key](../operations/key.md#rotate) | `rotate` | `kms.editor` for the key
[Changing the primary version](../operations/version.md#make-primary) | `setPrimaryVersion` | `kms.admin` for the key
[Destroying keys](../operations/key.md#delete) and [versions](../operations/version.md#delete)| `delete`, `scheduleVersionDestruction`, `cancelVersionDestruction` | `kms.admin` for the key
[Granting a role](../../iam/operations/roles/grant.md), [revoking a role](../../iam/operations/roles/revoke.md) | `setAccessBindings`, `updateAccessBindings` | `kms.admin` for the key
Viewing roles granted for a key | `listAccessBindings` | `kms.auditor` for the key

#### What's next {#what-is-next}

* [Secure use of Yandex Cloud](../../iam/best-practices/using-iam-securely.md)
* [How to assign a role](../../iam/operations/roles/grant.md).
* [How to revoke a role](../../iam/operations/roles/revoke.md).
* [Learn more about access management in Yandex Cloud](../../iam/concepts/access-control/index.md).
* [Learn more about role inheritance](../../resource-manager/concepts/resources-hierarchy.md#access-rights-inheritance).