01 Before you can create your own Customer-Managed Encryption Key (CMEK), you have to provision a key ring. A Cloud KMS key ring is a grouping of cryptographic keys made available for organizational purposes in a specific Google Cloud location. Run kms keyrings create command (Windows/macOS/Linux) to create a new Cloud KMS key ring in the specified location. If the keys deployed later within this key ring will be used to encrypt resources in a given region, select that region as the key ring location:
gcloud kms keyrings create cc-project5-key-ring
--location=us-central1
--project=cc-web-project-123123
--format="table(name)"
02 The command output should return the resource name of the newly created key ring:
NAME: projects/cc-web-project-123123/locations/us-central1/keyRings/cc-project5-key-ring
03 Run kms keys create command (Windows/macOS/Linux) to create a new Customer-Managed Encryption Key (CMEK) within the Cloud KMS key ring created at the previous steps:
gcloud kms keys create cc-eventarc-kms-key
--location=us-central1
--keyring=cc-project5-key-ring
--purpose=encryption
--protection-level=software
--rotation-period=90d
--next-rotation-time=2025-10-15T10:00:00.0000Z
--format="table(name)"
04 The command output should return the full resource name of the new Customer-Managed Encryption Key:
NAME: projects/cc-web-project-123123/locations/us-central1/keyRings/cc-project5-key-ring/cryptoKeys/cc-eventarc-kms-key
05 Run kms keys add-iam-policy-binding command (Windows/macOS/Linux) to add the required IAM policy binding to your CMEK. This assigns the Cloud KMS CryptoKey Encrypter/Decrypter role to the associated service account (i.e., the service account with the "eventarc.serviceAgentrole"). For example, service-\<project-number\>@gcp-sa-eventarc.iam.gserviceaccount.com):
gcloud kms keys add-iam-policy-binding cc-eventarc-kms-key
--keyring=cc-project5-key-ring
--location=us-central1
--member='serviceAccount:service-<project-number>@gcp-sa-eventarc.iam.gserviceaccount.com'
--role=roles/cloudkms.cryptoKeyEncrypterDecrypter
06 The command output should return the updated IAM policy (YAML format):
Updated IAM policy for key [cc-eventarc-kms-key].
bindings:
- members:
- serviceAccount:service-123456789012@gcp-sa-eventarc.iam.gserviceaccount.com
role: roles/cloudkms.cryptoKeyEncrypterDecrypter
etag: ABCD1234ABCD
version: 1
07 Run eventarc google-api-sources update command (Windows/macOS/Linux) to enable event message encryption with a Cloud KMS Customer-Managed Encryption Key (CMEK) for your Eventarc GoogleApiSource resource. For --crypto-key command parameter, specify the fully qualified identifier of the CMEK returned in step no 4:
gcloud beta eventarc google-api-sources update "projects/cc-web-project-123123/locations/us-central1/googleApiSources/google-api-source"
--location="us-central1"
--crypto-key="projects/cc-web-project-123123/locations/us-central1/keyRings/cc-project5-key-ring/cryptoKeys/cc-eventarc-kms-key"
08 The command output should return the update operation status:
Updating Google API source [google-api-source] in project [cc-web-project-123123], location [us-central1]...done.
09 Repeat steps no. 1 – 8 for each GCP project deployed in your Google Cloud account.