This page describes how to encrypt content stored in repositories with customer-managed encryption keys (CMEK).
Overview
By default, Artifact Registry encrypts customer content at rest. Artifact Registry handles encryption for you without any additional actions on your part. This option is called Google default encryption.
If you want to control your encryption keys, then you can use customer-managed encryption keys (CMEKs) in Cloud KMS with CMEK-integrated services including Artifact Registry. Using Cloud KMS keys gives you control over their protection level, location, rotation schedule, usage and access permissions, and cryptographic boundaries. Using Cloud KMS also lets you view audit logs and control key life cycles. Instead of Google owning and managing the symmetric key encryption keys (KEKs) that protect your data, you control and manage these keys in Cloud KMS.
After you set up your resources with CMEKs, the experience of accessing your Artifact Registry resources is similar to using Google default encryption. For more information about your encryption options, see Customer-managed encryption keys (CMEK).
You assign a CMEK key when you create a repository. You cannot change the encryption mechanism of an existing repository. If you have a CMEK-encrypted repository, then you cannot change the encryption mechanism to use a Google Cloud-powered encryption key or assign a different Cloud KMS key for encryption.
For more information about CMEK in general, including when and why to enable it, see the CMEK overview.
Creating a key and granting permissions
The following instructions explain how to create a key for a repository and grant permissions to encrypt and decrypt repository data with the key. You can use a key created directly in Cloud KMS or an externally-managed key that you make available with Cloud External Key Manager.
In the Trusted Cloud project where you want to manage your keys:
Create a key ring and a key using one of the following options:
If you have not created a repository in the Artifact Registry project, the Artifact Registry service account doesn't exist. To create the service account, run the following command:
gcloud beta services identity create --service=artifactregistry.googleapis.com --project=PROJECT
Replace PROJECT with the ID of the project where Artifact Registry is running.
Grant the CryptoKey Encrypter/Decrypter IAM role (
roles/cloudkms.cryptoKeyEncrypterDecrypter
) to the Artifact Registry service account. Grant this permission on the key you created.Console
Go to the Cryptographic keys page.
Select the key you created.
Grant access to the Artifact Registry service account:
- Select SHOW INFO PANEL.
- Click ADD MEMBER.
- Add the Artifact Registry service account. The service account is service-PROJECT-NUMBER@gcp-sa-artifactregistry.s3ns-system.iam.gserviceaccount.com, where PROJECT-NUMBER is the project number of the Trusted Cloud project where Artifact Registry is running.
- In Select a role, select Cloud KMS > Cloud KMS CryptoKey Encrypter/Decrypter.
- Click SAVE.
Repeat the previous step to grant access to the account that will create repositories.
Return to the Key management page and select the key again.
Select the SHOW INFO PANEL. You should see roles on the Role/Member column.
gcloud
Run the following command to grant access to the Artifact Registry service account:
gcloud kms keys add-iam-policy-binding [--project=PROJECT] \ KEY --location LOCATION --keyring=KEYRING \ --member serviceAccount:service-PROJECT-NUMBER@gcp-sa-artifactregistry.s3ns-system.iam.gserviceaccount.com \ --role roles/cloudkms.cryptoKeyEncrypterDecrypter
Where
- PROJECT is the ID of the project that contains the key.
- KEY is the key name.
- LOCATION is the key location.
- KEYRING is the key ring name.
- PROJECT-NUMBER is the project number of the Trusted Cloud project that is running Artifact Registry.
Repeat the previous step to grant access to the account that will create repositories.
For more information about this command see the gcloud kms keys add-iam-policy-binding documentation.
Next, create a repository and specify the key to use for encryption.
Removing access
There are several ways to remove access to a CMEK-encrypted repository:
- Revoke the Cloud KMS CryptoKey Encrypter/Decrypter role from the Artifact Registry service account using one of the following methods:
- Temporarily disable the Customer-managed encryption key
- Permanently destroy the CMEK key
We recommend that you revoke the permissions from the Artifact Registry service account before disabling or destroying a key. Changes to permissions are consistent within seconds, so you can observe the impacts of disabling or destroying a key.
When you disable or destroy the encryption key for a repository, you lose the
ability to view or retrieve artifact data. All artifact data stored in the
repository becomes inaccessible, including built artifacts, arbitrary binary
data (blobs), and manifests such as a Docker manifest or an npm packument file.
Users with the Artifact Registry Reader role
(roles/artifactregistry.reader
) or Viewer role
(roles/artifactregistry.viewer
) can still view artifact metadata such as the
artifact name, version, or tag.
Users with the Artifact Registry Administrator role
(roles/artifactregistry.admin
)
or Owner role (roles/owner
) can delete the repository.
CMEK organization policies
Artifact Registry supports organization policy constraints that can require CMEK protection.
Policies can limit which Cloud KMS CryptoKeys can be used for CMEK protection.
When Artifact Registry API is in the
Deny
policy list of services of constraintconstraints/gcp.restrictNonCmekServices
, Artifact Registry refuses to create new repositories that aren't CMEK-protected.When
constraints/gcp.restrictCmekCryptoKeyProjects
is configured, Artifact Registry creates CMEK-protected repositories that are protected by a CryptoKey from an allowed project, folder, or organization.
Pub/Sub supports the same constraints. When you activate the
Artifact Registry API in a Trusted Cloud by S3NS project, Artifact Registry
tries to automatically create a Pub/Sub topic with the topic ID
gcr
using Google Cloud-powered encryption keys. However, if the Pub/Sub API is in
the Deny
policy list for the constraint
constraints/gcp.restrictNonCmekServices
, then
Pub/Sub won't create the topic. In this scenario, you must
create the gcr
topic
with CMEK encryption. For more information, see the Pub/Sub
instructions for encrypting topics.
For more about configuring organization policies, see CMEK organization policies.
What's next?
- Create a repository encrypted with CMEK
- Learn more about CMEK