Enabling customer-managed encryption keys

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 lifecycles. 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).

CMEK with Cloud KMS Autokey

You can either create CMEKs manually to protect your Artifact Registry resources or use Cloud KMS Autokey. With Autokey, key rings and keys are generated on demand to support resource creation in Artifact Registry. Service agents that use the keys for encrypt and decrypt operations are created if they don't already exist and are granted the required Identity and Access Management (IAM) roles. For more information, see Autokey overview.

To set up CMEK manually, see Creating a key and granting permissions

To set up CMEK using Autokey, see Use Autokey to create keys on this page.

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-owned and Google-managed 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.

  1. In the Google Cloud project where you want to manage your keys:

    1. Enable the Cloud KMS API.

    2. Create a key ring and a key using one of the following options:

      The Cloud KMS key location must match the repository location of the repository you will encrypt.

  2. 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.

  3. 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

    1. Go to the Cryptographic keys page.

      Open the Cloud KMS page

    2. Select the key you created.

    3. Grant access to the Artifact Registry service account:

      1. Select SHOW INFO PANEL.
      2. Click ADD MEMBER.
      3. Add the Artifact Registry service account. The service account is service-PROJECT-NUMBER@gcp-sa-artifactregistry.iam.gserviceaccount.com, where PROJECT-NUMBER is the project number of the Google Cloud project where Artifact Registry is running.
      4. In Select a role, select Cloud KMS > Cloud KMS CryptoKey Encrypter/Decrypter.
      5. Click SAVE.
    4. Repeat the previous step to grant access to the account that will create repositories.

    5. Return to the Key management page and select the key again.

    6. Select the SHOW INFO PANEL. You should see roles on the Role/Member column.

    gcloud

    1. Run the following command to grant access to the Artifact Registry service account:

      gcloud kms keys add-iam-policy-binding [--project=PROJECT]