*This page
applies to **Apigee** , but not to **Apigee hybrid**.*


*View [Apigee Edge](https://docs.apigee.com/api-platform/get-started/what-apigee-edge) documentation.*
![](https://fonts.gstatic.com/s/i/googlematerialicons/help/v13/gm_grey-24dp/1x/gm_help_gm_grey_24dp.png)

This section describes the types of encryption keys and how to create them.

For information on monitoring EKM health, see [EKM health monitoring](https://docs.cloud.google.com/apigee/docs/api-platform/security/ekm-monitoring.md.txt).

> [!NOTE]
> **Note:** The EKM monitoring feature is available only for Apigee organizations that were configured to use CMEK with EKM when the organization was created. It is not possible to enable this feature for existing organizations.

During the Apigee setup process, you generate the following
[Cloud Key Management Service](https://cloud.google.com/security/products/security-key-management) encryption keys:

| Key Type | When Created | Description |
|---|---|---|
| Control plane encryption key | Google Cloud console: - [Step 3: Configure hosting and encryption (Subscription)](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/create-org) - [Step 3: Configure hosting and encryption (Pay-as-you-go)](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/console-configure-hosting.md.txt) Command line interface (CLI): - [Step 5: Create an organization (Subscription and Pay-as-you-go)](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/install-cli.md.txt#create-org) | When using [data residency](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-concepts.md.txt), Apigee uses this key to encrypt Analytics data stored in BigQuery inside the tenant project. Encrypts API proxies, Target Servers, Truststores and Keystores, analytic data, and anything else shared across runtimes. Apigee will ask you to provide two control plane CMEK keys. This key, and an [API consumer data encryption key](https://docs.cloud.google.com/apigee/docs/api-platform/security/encryption-keys.md.txt#api-consumer-data-ek). The control plane encryption key's location should match the control plane location. > [!WARNING] > **Warning:** Choose your key's location carefully. Once set, the key and key location cannot be changed. |
| API consumer data encryption key | Google Cloud console: - [Step 3: Configure hosting and encryption (Subscription)](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/create-org) - [Step 3: Configure hosting and encryption (Pay-as-you-go)](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/console-configure-hosting.md.txt) Command line interface (CLI): - [Step 5: Create an organization (Subscription and Pay-as-you-go)](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/install-cli.md.txt#create-org) | When using [data residency](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-concepts.md.txt), Apigee needs a single region key, in addition to the [control plane encryption key](https://docs.cloud.google.com/apigee/docs/api-platform/security/encryption-keys.md.txt#control-plane-ek), that is used for services that are available only in a single region. For example, Dataflow, and Cloud SQL. The API consumer data encryption key's location should be within the control plane location. > [!WARNING] > **Warning:** Choose your key's location carefully. Once set, the key and the key location cannot be changed. |
| Runtime database encryption key | Google Cloud console: - [Step 3: Configure hosting and encryption (Subscription)](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/create-org) - [Step 3: Configure hosting and encryption (Pay-as-you-go)](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/console-configure-hosting.md.txt) Command line interface (CLI): - [Step 5: Create an organization (Subscription and Pay-as-you-go)](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/install-cli.md.txt#create-org) | Encrypts application data such as , cache, and client secrets, which is then stored in the database. There is one runtime database encryption key per organization --- all instances/regions in an organization share the same runtime database encryption key. The runtime database encryption key supports all Cloud KMS locations that support [Cloud HSM](https://docs.cloud.google.com/kms/docs/hsm.md.txt) and [Cloud EKM](https://docs.cloud.google.com/kms/docs/ekm.md.txt). Google recommends using a [multi-regional location](https://docs.cloud.google.com/kms/docs/locations.md.txt#multi_regional) (such as `us` or `europe`) or [dual-regional location](https://docs.cloud.google.com/kms/docs/locations.md.txt#dual_regional) (`eur5`, `nam4`) when you create this key. The runtime database encryption key's location should be within the control plane location when using [data residency](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-concepts.md.txt). > [!WARNING] > **Warning:** Choose your key's location carefully. Once set, the key and the key location cannot be changed. |
| Disk encryption key | Google Cloud console: - [Step 5: Configure hosting and encryption (Subscription)](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/create-instance) - [Step 3: Configure hosting and encryption (Pay-as-you-go)](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/console-configure-hosting.md.txt) Command line interface (CLI): - [Step 6: Create a runtime instance (Subscription and Pay-as-you-go)](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/install-cli.md.txt#runtime-instance) | Encrypts runtime instance data before it is written to disk. The types of data encrypted include Key Management System (KMS); Key Value Maps (KVMs); quota definitions, buckets, and counters; and all cached data. KMS data includes API products, developers, developer apps, OAuth tokens (including access tokens, refresh tokens, and authorization codes), and API keys. This key is located in the same region as the runtime instance; when creating a new key, match the key's location to your runtime instance's location. Each instance/region combination has its own disk encryption key. |

## Key points

Keep the following in mind when creating the disk and runtime database encryption keys:

- The location of the Apigee runtime database encryption key supports all Cloud KMS locations that support [Cloud HSM](https://docs.cloud.google.com/kms/docs/hsm.md.txt) and [Cloud EKM](https://docs.cloud.google.com/kms/docs/ekm.md.txt).
- The disk encryption key's location must match the location of the runtime instance that the key is used in.
- Once set, you cannot change the location of either key.
- All keys must be in a key ring.
- Keys of different types must be in separate key rings; disk encryptions keys cannot be in the same key ring as your runtime database encryption key.
- The keys must have a `purpose`. If you use the command line to generate your new keys, set `purpose` to `encryption`. If you use the Google Cloud console, choose **Symmetric
  encrypt/decrypt** for the purpose.
- The keys are defined by a *key path* , which uses the following pattern:

  ```
  projects/PROJECT_ID/locations/KEY_LOCATION/keyRings/KEYRING_NAME/cryptoKeys/KEY_NAME
  ```

## Listing existing keys

If you already created new Cloud KMS encryption keys for
Apigee, you can use those rather than create new keys during your
setup.

To list all KMS keys in a key ring:

Execute the [`gcloud kms keys list`](https://docs.cloud.google.com/sdk/gcloud/reference/kms/keys/list) command:

```
gcloud kms keys list --keyring KEY_RING_NAME --location KEY_RING_LOCATION
```

Replace the following:

- <var translate="no">KEY_RING_NAME</var>: the name of the key ring. For example, `my-key-ring`.
- <var translate="no">KEY_RING_LOCATION</var>: the physical location of the key ring, For example, `us-west1`.

Alternatively, you can [view your keys in the Google Cloud console](https://docs.cloud.google.com/kms/docs/view-keys-by-project.md.txt#view-keys).

## Generating new keys on the command line

You can create a key ring and key on the command line or in
[the Google Cloud console](https://docs.cloud.google.com/apigee/docs/api-platform/security/encryption-keys.md.txt#generate-key-console).

Each type of key must have its own key ring. For example, your disk
encryption keys can be stored in one key ring, but your runtime database
encryption key must be stored in a separate key ring.


The following steps describe how to create a key ring and a key, and how to
grant access for the Apigee Service Agent to use the new key. Create
key rings and keys for the control plane (if using data residency), the
runtime database, and the runtime disk.

1. Create a new key ring using the
   [`gcloud kms keyrings create`](https://docs.cloud.google.com/sdk/gcloud/reference/kms/keyrings/create) command:

   ### Control plane


   When [data residency](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-concepts.md.txt) is enabled, create a key ring for the control
   plane, and another for the consumer data region.

   ```
   gcloud kms keyrings create CONTROL_PLANE_KEY_RING_NAME \
   --location CONTROL_PLANE_LOCATION \
   --project PROJECT_ID
   ```

   ```
   gcloud kms keyrings create CONSUMER_DATA_KEY_RING_NAME \
   --location CONSUMER_DATA_REGION \
   --project PROJECT_ID
   ```

   Replace the following:
   - <var translate="no">CONTROL_PLANE_KEY_RING_NAME</var>: the control plane key ring name.
   - <var translate="no">CONTROL_PLANE_LOCATION</var>: the physical location at which Apigee control plane data will be stored.
   - <var translate="no">PROJECT_ID</var>: the Google Cloud project ID.
   - <var translate="no">CONSUMER_DATA_KEY_RING_NAME</var>: the consumer data key ring name.
   - <var translate="no">CONSUMER_DATA_REGION</var>: a sub-region of the control plane region. You must specify both the CONTROL_PLANE_LOCATION and the CONSUMER_DATA_REGION.

   ### Runtime database

   ```
   gcloud kms keyrings create RUNTIMEDB_KEY_RING_NAME \
     --location RUNTIMEDB_KEY_LOCATION \
     --project PROJECT_ID
   ```

   Replace the following:
   - <var translate="no">RUNTIMEDB_KEY_RING_NAME</var>: the name of the database key ring you are creating.
   - <var translate="no">RUNTIMEDB_KEY_LOCATION</var>: the physical location of the database key ring.
   - <var translate="no">PROJECT_ID</var>: the Google Cloud project ID.


   The Apigee encryption key's location supports all Cloud KMS
   locations that support [Cloud HSM](https://docs.cloud.google.com/kms/docs/hsm.md.txt) and
   [Cloud EKM](https://docs.cloud.google.com/kms/docs/ekm.md.txt).

   ### Runtime disk

   ```
   gcloud kms keyrings create RUNTIMEDISK_KEY_RING_NAME \
     --location RUNTIMEDISK_KEY_LOCATION \
     --project PROJECT_ID
   ```

   Replace the following:
   - <var translate="no">RUNTIMEDISK_KEY_RING_NAME</var>: the name of the disk key ring you are creating.
   - <var translate="no">RUNTIMEDISK_KEY_LOCATION</var>: the physical location of the disk key ring.
   - <var translate="no">PROJECT_ID</var>: the Google Cloud project ID.


   Verify that the disk key ring is set to the same location as the
   instance. Each instance and key ring should have its own location.

   ```
   gcloud kms keyrings list \
   --location  \
   --project $PROJECT_ID
   ```

   <br />

   ```
   gcloud kms keyrings describe $DISK_KEY_RING_NAME \
   --location  \
   --project $PROJECT_ID
   ```
2. The key ring's name must be unique to your organization. If you create additional regions, the key ring names for those regions cannot be the same as existing key ring names.
3. Create a key using the
   [`kms keys create`](https://docs.cloud.google.com/sdk/gcloud/reference/kms/keys/create.md.txt) command:

   ### Control plane


   When [data residency](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-concepts.md.txt) is enabled, create a key ring for the control
   plane, and another for the consumer data region.

   ```
   gcloud kms keys create CONTROL_PLANE_KEY_NAME \
   --keyring CONTROL_PLANE_KEY_RING_NAME \
   --location CONTROL_PLANE_LOCATION \
   --purpose "encryption" \
   --project PROJECT_ID
   ```

   ```
   gcloud kms keys create CONSUMER_DATA_KEY_NAME \
   --keyring CONSUMER_DATA_KEY_RING_NAME \
   --location CONSUMER_DATA_REGION \
   --purpose "encryption" \
   --project PROJECT_ID
   ```

   Replace the following:
   - <var translate="no">CONTROL_PLANE_KEY_NAME</var>: the control plane key name.
   - <var translate="no">CONTROL_PLANE_KEY_RING_NAME</var>: the control plane key ring name.
   - <var translate="no">CONTROL_PLANE_LOCATION</var>: the physical location at which Apigee control plane data will be stored.
   - <var translate="no">PROJECT_ID</var>: the Google Cloud project ID.
   - <var translate="no">CONSUMER_DATA_KEY_NAME</var>: the consumer data key name.
   - <var translate="no">CONSUMER_DATA_KEY_RING_NAME</var>: the consumer data key ring name.
   - <var translate="no">CONSUMER_DATA_REGION</var>: a sub-region of the control plane region. You must specify both the CONTROL_PLANE_LOCATION and the CONSUMER_DATA_REGION.

   ### Runtime database

   ```
   gcloud kms keys create RUNTIMEDB_KEY_NAME \
     --keyring RUNTIMEDB_KEY_RING_NAME \
     --location RUNTIMEDB_KEY_LOCATION \
     --purpose "encryption" \
     --project PROJECT_ID
   ```

   Replace the following:
   - <var translate="no">RUNTIMEDB_KEY_NAME</var>: the name of the database key you are creating.
   - <var translate="no">RUNTIMEDB_KEY_RING_NAME</var>: the name of the database key ring you are creating.
   - <var translate="no">RUNTIMEDB_KEY_LOCATION</var>: the physical location of the database key ring.
   - <var translate="no">PROJECT_ID</var>: the Google Cloud project ID.

   ### Runtime disk

   ```
   gcloud kms keys create RUNTIMEDISK_KEY_NAME \
     --keyring RUNTIMEDISK_KEY_RING_NAME \
     --location RUNTIMEDISK_KEY_LOCATION \
     --purpose "encryption" \
     --project PROJECT_ID
   ```

   Replace the following:
   - <var translate="no">RUNTIMEDISK_KEY_NAME</var>: the name of the disk key you are creating.
   - <var translate="no">RUNTIMEDISK_KEY_RING_NAME</var>: the name of the disk key ring you are creating.
   - <var translate="no">RUNTIMEDISK_KEY_LOCATION</var>: the physical location of the disk key ring.
   - <var translate="no">PROJECT_ID</var>: the Google Cloud project ID.

   This command creates the key and adds it to the key ring.

   When you refer to a key, use the [key ID](https://docs.cloud.google.com/apigee/docs/api-platform/security/encryption-keys.md.txt#get-key-id).
4. Grant access for the Apigee Service Agent to use the new key using the
   [`gcloud kms keys add-iam-policy-binding`](https://docs.cloud.google.com/sdk/gcloud/reference/kms/keys/add-iam-policy-binding) command:

   ### Control plane


   When [data residency](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-concepts.md.txt) is enabled, create a key ring for the control
   plane, and another for the consumer data region.

   ```
   gcloud kms keys add-iam-policy-binding CONTROL_PLANE_KEY_NAME \
   --location CONTROL_PLANE_LOCATION \
   --keyring CONTROL_PLANE_KEY_RING_NAME \
   --member "serviceAccount:service-PROJECT_NUMBER@gcp-sa-apigee.iam.gserviceaccount.com" \
   --role roles/cloudkms.cryptoKeyEncrypterDecrypter \
   --project PROJECT_ID
   ```

   ```
   gcloud kms keys add-iam-policy-binding CONSUMER_DATA_KEY_NAME \
   --location CONSUMER_DATA_REGION \
   --keyring CONSUMER_DATA_KEY_RING_NAME \
   --member "serviceAccount:service-PROJECT_NUMBER@gcp-sa-apigee.iam.gserviceaccount.com" \
   --role roles/cloudkms.cryptoKeyEncrypterDecrypter \
   --project PROJECT_ID
   ```

   Replace the following:
   - <var translate="no">CONTROL_PLANE_KEY_NAME</var>: the control plane key name.
   - <var translate="no">CONTROL_PLANE_LOCATION</var>: the physical location at which Apigee control plane data will be stored.
   - <var translate="no">CONTROL_PLANE_KEY_RING_NAME</var>: the control plane key ring name.
   - <var translate="no">PROJECT_NUMBER</var>: the Google Cloud project number.
   - <var translate="no">PROJECT_ID</var>: the Google Cloud project ID.
   - <var translate="no">CONSUMER_DATA_KEY_NAME</var>: the consumer data key name.
   - <var translate="no">CONSUMER_DATA_REGION</var>: a sub-region of the control plane region. You must specify both the CONTROL_PLANE_LOCATION and the CONSUMER_DATA_REGION.
   - <var translate="no">CONSUMER_DATA_KEY_RING_NAME</var>: the consumer data key ring name.

   ### Runtime database

   ```
   gcloud kms keys add-iam-policy-binding RUNTIMEDB_KEY_NAME \
     --location RUNTIMEDB_KEY_LOCATION \
     --keyring RUNTIMEDB_KEY_RING_NAME \
     --member serviceAccount:service-PROJECT_NUMBER@gcp-sa-apigee.iam.gserviceaccount.com \
     --role roles/cloudkms.cryptoKeyEncrypterDecrypter \
     --project PROJECT_ID
   ```

   Replace the following:
   - <var translate="no">RUNTIMEDB_KEY_NAME</var>: the name of the database key you are creating.
   - <var translate="no">RUNTIMEDB_KEY_RING_NAME</var>: the name of the database key ring you are creating.
   - <var translate="no">RUNTIMEDB_KEY_LOCATION</var>: the physical location of the database key ring.
   - <var translate="no">PROJECT_NUMBER</var>: the Google Cloud project number.
   - <var translate="no">PROJECT_ID</var>: the Google Cloud project ID.

   ### Runtime disk

   ```
   gcloud kms keys add-iam-policy-binding RUNTIMEDISK_KEY_NAME \
     --location RUNTIMEDISK_KEY_LOCATION \
     --keyring RUNTIMEDISK_KEY_RING_NAME \
     --member serviceAccount:service-PROJECT_NUMBER@gcp-sa-apigee.iam.gserviceaccount.com \
     --role roles/cloudkms.cryptoKeyEncrypterDecrypter \
     --project PROJECT_ID
   ```

   Replace the following:
   - <var translate="no">RUNTIMEDISK_KEY_NAME</var>: the name of the disk key you are creating.
   - <var translate="no">RUNTIMEDISK_KEY_RING_NAME</var>: the name of the disk key ring you are creating.
   - <var translate="no">RUNTIMEDISK_KEY_LOCATION</var>: the physical location of the disk key ring.
   - <var translate="no">PROJECT_NUMBER</var>: the Google Cloud project number.
   - <var translate="no">PROJECT_ID</var>: the Google Cloud project ID.

   This command binds the key to the Apigee Service Agent.


   On successful completion of this request, `gcloud` responds
   with something similar to the following:

   ```
   Updated IAM policy for key [runtime].
   bindings:
   - members:
   - serviceAccount:service-1234567890@gcp-sa-apigee.iam.gserviceaccount.com
   role: roles/cloudkms.cryptoKeyEncrypterDecrypter
   etag: BwWqgEuCuwk=
   version: 1
   ```

   If you receive an error like the following:

   ```
   INVALID_ARGUMENT: Role roles/cloudkms.cryptokms.cryptoKeyEncrypterDecrypter is not supported for this resource.
   ```


   Be sure that you used the project number and not the project name in the
   service account email address.

   To verify that the key is bound to the Apigee Service Agent:

   ```
   gcloud kms keys get-iam-policy $DISK_KEY_NAME \
     --keyring $DISK_KEY_RING_NAME \
     --location  \
     --project $PROJECT_ID
   ```

   <br />

   ```
   gcloud kms keys describe $DISK_KEY_NAME \
     --keyring $DISK_KEY_RING_NAME \
     --location  \
     --project $PROJECT_ID
   ```

## Generating new keys using the Google Cloud console

You can generate new keys using the console, as described in
[Create a symmetric encryption key](https://docs.cloud.google.com/kms/docs/create-key.md.txt#create-symmetric).

When you use the console to create a new key:

- For the runtime database encryption key, set the location to any Cloud KMS location that supports [Cloud HSM](https://docs.cloud.google.com/kms/docs/hsm.md.txt) and [Cloud EKM](https://docs.cloud.google.com/kms/docs/ekm.md.txt). The UI does not let you choose any other location for the key, so it will match what you choose in the key ring.
- After you create the key, get the key path in the **Cryptographic keys** pane by clicking **More** next to the key and then selecting **Copy Resource Name**.

## Get the key ID


When you refer to a Cloud Key Management Service resource using the
Cloud KMS API or Google Cloud CLI, you use the resource ID. You can
get the key ID with the [`gcloud kms keys list`](https://docs.cloud.google.com/sdk/gcloud/reference/kms/keys/list) command:

### Control plane


When [data residency](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/drz-concepts.md.txt) is enabled, there is a key ring for the control
plane, and another for the consumer data region.

```
gcloud kms keys list \
--location=CONTROL_PLANE_LOCATION \
--keyring=CONTROL_PLANE_KEY_RING_NAME \
--project=PROJECT_ID
```

<br />

```
gcloud kms keys list \
--location=CONSUMER_DATA_REGION \
--keyring=CONSUMER_DATA_KEY_RING_NAME \
--project=PROJECT_ID
```

The key ID has the following syntax (similar to a file path):

```
projects/PROJECT_ID/locations/CONTROL_PLANE_LOCATION/keyRings/CONTROL_PLANE_KEY_RING_NAME/cryptoKeys/CONTROL_PLANE_KEY_NAME
```

### Runtime database

```
gcloud kms keys list \
--location=RUNTIMEDB_KEY_LOCATION \
--keyring=RUNTIMEDB_KEY_RING_NAME \
--project=PROJECT_ID
```

The key ID has the following syntax (similar to a file path):

```
projects/PROJECT_ID/locations/RUNTIMEDB_KEY_LOCATION/keyRings/RUNTIMEDB_KEY_RING_NAME/cryptoKeys/RUNTIMEDB_KEY_NAME
```

### Runtime disk

```
gcloud kms keys list \
  --location=RUNTIMEDISK_KEY_LOCATION \
  --keyring=RUNTIMEDISK_KEY_RING_NAME \
  --project=PROJECT_ID
```

The key ID has the following syntax (similar to a file path):

```
projects/PROJECT_ID/locations/RUNTIMEDISK_KEY_LOCATION/keyRings/RUNTIMEDISK_KEY_RING_NAME/cryptoKeys/RUNTIMEDISK_KEY_NAME
```

For example:

```
NAME: projects/my-project/locations/us-west1/keyRings/my-key-ring/cryptoKeys/my-key
PURPOSE: ENCRYPT_DECRYPT
ALGORITHM: GOOGLE_SYMMETRIC_ENCRYPTION
PROTECTION_LEVEL: SOFTWARE
LABELS:
PRIMARY_ID: 1
PRIMARY_STATE: ENABLED
```

You can also get the key ID in the Google Cloud console. For more
information, see
[Getting a Cloud KMS
resource ID](https://docs.cloud.google.com/kms/docs/getting-resource-ids).

*[KVMs]: Key Value Maps