Secure use of Yandex Cloud
This section provides recommendations on how to make the best use of IAM for secure work with Yandex Cloud services.
Do not grant unnecessary access rights
For critical resources:
-
Assign the minimum required roles. For example, to allow the creation of virtual machines from images in Compute Cloud, assign
compute.images.user
role instead of theeditor
role or higher. -
Try to assign service roles rather than primitive roles (
viewer
,editor
,admin
). Primitive roles apply to resources in any service Yandex Cloud.Use primitive roles if there is no suitable service role or you want to confer broad authority on a user.
-
Assign only roles you need right now. Do not assign roles you may only need in the future.
-
Note that when you assign a role for a folder, cloud, or organization, all the nested resources will inherit this role's permissions.
-
Only assign the administrator role or cloud owner role to the people responsible for managing resource access in your project.
An administrators can revoke another administrator's access rights, and an owner can revoke another owner's owner role. These roles also include all the permissions under the
editor
role allowing to create, edit, and delete resources.
Protect your Yandex account
-
To better safeguard your resources from unauthorized access, enable Yandex ID two-factor authentication
. Also, request users you add to your organization to enable it. -
Keep your OAuth token a secret, since it can be used to get an IAM token and perform operations in the cloud on behalf of you.
If someone might have discovered your OAuth token, invalidate it
and issue a new one. -
Avoid using your OAuth token for authentication if you can use an IAM token. OAuth tokens are valid for 1 year while IAM tokens are valid for 12 hours. If your token is compromised, the hacker has limited time to use it.
Use service accounts
Use service accounts to automate work with Yandex Cloud and follow these recommendations:
-
Control access to your service accounts. The
editor
role for a service account allows the user to perform operations this service account is authorized to perform. If the service account is the cloud administrator, the user can use it to make themselves an administrator. -
Create separate service accounts for different tasks. This way you can only assign them the roles you actually need. You can revoke roles from a service account or delete it without affecting other service accounts.
-
Name your service accounts according to their intended purposes and permissions.
-
Keep your service account keys secret: they can be used to perform operations under your service account. Do not keep your service account keys in the source code.
Revoke old keys and issue new ones every now and then. Be sure to do this if you think someone has learned your secret key.
-
Do not use your keys for authentication if you can use IAM tokens. Keys have an unlimited lifetime, while IAM tokens are valid for 12 hours.
-
If you perform operations from inside a VM, link a service account to it. Thus you will no longer need to store your service account keys on the VM for authentication: your IAM token will be available by a metadata service link.