Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you share Google Cloud KMS keys across projects with service roles?

This GCP article suggests using two separate projects: one for key management, another for encryption/decryption.

This seems like a setup that works with User roles, but not with Service roles as a Service role is bound to the project it belongs to. Am I missing something?

Is there actually a way to have one role (in, let's say, Project 1), that creates KMS keys, and then have a service role (in, let's say, Project 2) that can access said keys at runtime for decryption?

like image 627
Venantius Avatar asked Mar 10 '18 21:03

Venantius


People also ask

Is KMS global or regional?

Even though KMS is a global service but keys are regional that means you can't send keys outside the region in which they are created.

What is the initial encryption support required for management using cloud key management services?

Cloud KMS stores AES-265 encryption keys in a five level hierarchy. The top level, called GCP Project, manages Identity and Access Management roles for accounts associated with a specific cloud project, which can be linked to an organization or a department within it, for instance.

What is CMEK in Google Cloud?

If you need more control over the keys used to encrypt data at rest within a Google Cloud project, several Google Cloud services offer the ability to protect data related to those services using encryption keys managed by the customer within Cloud KMS.


1 Answers

It's possible! You can add an IAM policy with the principal(member) & resource in different projects.

To grant [email protected] decryption access to a particular key in project1, you can e.g.:

$ KMS_KEY_RESOURCE_NAME=projects/project1/locations/${location}/keyRings/${keyring_name}/cryptoKeys/${crypto_key_name}
$ gcloud kms keys add-iam-policy-binding \
  --location ${location} ${KMS_KEY_RESOURCE_NAME} \
  --member serviceAccount:[email protected] \
  --role roles/cloudkms.cryptoKeyDecrypter

You can also do this by pasting [email protected] directly into the "Add members" textbox under "Permissions" for a KeyRing or Key selected under http://console.cloud.google.com/iam-admin/kms?project=project1

like image 51
Phil Coakley Avatar answered Oct 17 '22 14:10

Phil Coakley