In Cloud KMS, resources are organized into a hierarchy. This hierarchy helps you manage and grant access to resources at various levels of granularity. Keys are contained within key rings, and key rings exist within a project. EKM connections also exist within a project. Projects can be further organized into folders or organizations.
This topic provides more details about the hierarchy of resources within Cloud KMS. To learn more about Google Cloud resources in general, see Resource hierarchy.
Resource hierarchy
The scope of an IAM role changes depending on the level of the resource
hierarchy where the role is granted. This table shows the effective capabilities
granted by the Cloud KMS CryptoKey Encrypter role
(roles/cloudkms.cryptoKeyEncrypter
) at different levels of the hierarchy.
You can manage access to keys or key rings, but not to individual key versions.
Resource hierarchy | Capability |
---|---|
Organization | Encrypt using all keys in all projects in the organization |
Folder | Encrypt using all keys in all projects in the folder |
Project | Encrypt using all keys in the project |
Key ring | Encrypt using all keys on the key ring |
Key | Encrypt using only that key |
Security principles
IAM helps enforce the interrelated security principles of separation of duties and least privilege:
When you enforce the principle of separation of duties, no single member has all of the access required to complete a critical business function. For example, a bank teller can only withdraw funds from an account when the account holder is physically present and initiates the transaction.
When you enforce the principle of least privilege, a member has only the minimum level of access required to complete that member's specific business functions. For example, a bank teller is not automatically granted the ability to approve a customer loan.
Predefined roles
IAM provides predefined roles that grant access for each kind of Google Cloud resources. If no predefined role meets your needs, you can create a custom role.
IAM offers the following predefined roles for Cloud KMS:
Role | Permissions |
---|---|
Cloud KMS Admin( Provides access to Cloud KMS resources, except for access to restricted resource types and cryptographic operations. Lowest-level resources where you can grant this role:
|
|
Cloud KMS Autokey Admin( Enables management of AutokeyConfig. |
|
Cloud KMS Autokey User( Grants ability to use KeyHandle resources. |
|
Cloud KMS CryptoKey Decrypter( Provides ability to use Cloud KMS resources for decrypt operations only. Lowest-level resources where you can grant this role:
|
|
Cloud KMS CryptoKey Decrypter Via Delegation( Enables Decrypt operations via other Google Cloud services |
|
Cloud KMS CryptoKey Encrypter( Provides ability to use Cloud KMS resources for encrypt operations only. Lowest-level resources where you can grant this role:
|
|
Cloud KMS CryptoKey Encrypter/Decrypter( Provides ability to use Cloud KMS resources for encrypt and decrypt operations only. Lowest-level resources where you can grant this role:
|
|
Cloud KMS CryptoKey Encrypter/Decrypter Via Delegation( Enables Encrypt and Decrypt operations via other Google Cloud services |
|
Cloud KMS CryptoKey Encrypter Via Delegation( Enables Encrypt operations via other Google Cloud services |
|
Cloud KMS Crypto Operator( Enables all Crypto Operations. |
|
Cloud KMS EkmConnections Admin( Enables management of EkmConnections. |
|
Cloud KMS Expert Raw AES-CBC Key Manager( Enables raw AES-CBC keys management. |
|
Cloud KMS Expert Raw AES-CTR Key Manager( Enables raw AES-CTR keys management. |
|
Cloud KMS Expert Raw PKCS#1 Key Manager( Enables raw PKCS#1 keys management. |
|
Cloud KMS Importer( Enables ImportCryptoKeyVersion, CreateImportJob, ListImportJobs, and GetImportJob operations |
|
Cloud KMS Protected Resources Viewer( Enables viewing protected resources. |
|
Cloud KMS CryptoKey Public Key Viewer( Enables GetPublicKey operations |
|
Cloud KMS CryptoKey Signer( Enables Sign operations |
|
Cloud KMS CryptoKey Signer/Verifier( Enables Sign, Verify, and GetPublicKey operations |
|
Cloud KMS CryptoKey Verifier( Enables Verify and GetPublicKey operations |
|
Cloud KMS Viewer( Enables Get and List operations. |
|
Custom roles
In addition to predefined roles, you can create custom roles. Custom roles allow you to enforce the principle of least privilege by granting the role the minimum permissions required to perform a given task.
A custom role includes one or more of the permissions listed in the
IAM reference.
Permissions related to the Cloud Key Management Service API begin with the string cloudkms
.
For more information, see
Support levels for permissions in custom roles.
For information about the permissions required to invoke a specific Cloud Key Management Service API method, see that method's API reference.
General guidelines for managing access in Cloud KMS
We recommend that you avoid using basic project-wide roles like owner
,
editor
, and viewer
. These roles do not separate the ability to manage keys
from the ability to use the keys for cryptographic operations, and are not
recommended for production environments. Instead, use predefined roles or create
custom roles that reflect your business requirements.
The following examples help illustrate some good security guidelines:
For a large or complex organization, you might decide on an approach like the following:
- Grant members of your IT security team the Cloud KMS Admin role
(
roles/cloudkms.admin
) across all projects. If different team members handle different aspects of a key's lifecycle, you can grant those team members a more granular role, like the Cloud KMS Importer role (roles/cloudkms.importer
). - Grant the Cloud KMS Encrypter / Decrypter role
(
roles/cloudkms.cryptoKeyEncrypterDecrypter
) to users or applications that read or write encrypted data. - Grant the Cloud KMS Public Key Viewer role
(
roles/cloudkms.publicKeyViewer
) to users or applications that need to view the public portion of a key used for asymmetric encryption. - Create predefined roles that match your business requirements. For example, the same user might need to monitor a project's quotas and to view log data.
- Grant members of your IT security team the Cloud KMS Admin role
(
For a small organization with simple security requirements, you might choose to take a simpler approach by granting a broad role such as Organization Admin (
roles/resourcemanager.organizationAdmin
). However, this approach might not scale with your ongoing requirements.Consider hosting your keys in a separate Google Cloud project from the data protected by those keys. A user with a basic or highly privileged role in one project, such as
editor
, cannot use this role to gain unauthorized access to keys in a different project.Avoid granting the
owner
role to any member. Without theowner
role, no member in the project can both create a key and use it to decrypt data or for signing, unless each of these permissions is granted to that member. To grant broad administrative access without granting the ability to encrypt or decrypt, grant the Cloud KMS Admin role (roles/cloudkms.admin
) role instead.To limit access to encrypted data, such as customer data, you can restrict who can access the key and who can use the key for decryption. If necessary, you can create granular custom roles to meet your business requirements.
Checking permissions
For each Cloud KMS object type for which you can set granular
IAM permissions, that object has a testIamPermissions
method.
The testIamPermissions
method returns the set of permissions the caller has
been granted for that object.
- For key rings, you can invoke the
cloudkms.keyRings.testIamPermissions
method. - For keys, you can invoke the
cloudkms.cryptoKeys.testIamPermissions
method. - For key import jobs, you can invoke the
cloudkms.keyRings.importJobs.testIamPermissions
method. - For EKM connections,
you can invoke the
cloudkms.ekmConnections.testIamPermissions
method.
You cannot set IAM permissions on a key version, so the
CryptoKeyVersion
object type does not have this method.
An object's testIamPermissions
method returns a
TestIamPermissionsResponse
.
For examples of invoking testIamPermissions
methods, see the documentation for
testing permissions in the IAM
documentation.
What's next
- Learn how IAM centralizes management of permissions and access scopes for Google Cloud resources.
- Understand the different types of Cloud KMS objects.