Skip to main content

More Info:

Ensure that Vertex AI datasets are encrypted using Customer-Managed Encryption Keys

Risk Level

Medium

Address

Security

Compliance Standards

  • CIS GCP

Triage and Remediation

Remediation

Using Console

Below are the console-based steps to ensure Vertex AI datasets are encrypted with Customer-Managed Encryption Keys (CMEK). Note that CMEK can only be specified when creating a dataset; you can’t change the encryption key of an existing dataset.

1. Create or identify a CMEK key

  1. In the Google Cloud Console, go to:
    SecurityKey Management (or search “KMS” / “Key Management”).
  2. Make sure you are in the same project and region that your Vertex AI resources will use.
  3. If needed, create a key ring:
    • Click Create key ring.
    • Give it a Name and select the Location (match your Vertex AI region, e.g., us-central1).
    • Click Create.
  4. Create a key:
    • Inside the key ring, click Create key.
    • Choose Key purpose = Symmetric encrypt/decrypt.
    • Configure rotation if desired; accept defaults or customize.
    • Click Create.

2. Grant Vertex AI permission to use the key

Vertex AI uses a service agent to access CMEK. You must grant it Encrypter/Decrypter on the CryptoKey.
  1. In Cloud Console, still under SecurityKey Management:
    • Click the key ring, then the key you will use.
  2. Go to the Permissions tab.
  3. Click Grant access.
  4. In New principals, add the Vertex AI service agent for your project:
    Replace PROJECT_NUMBER with your actual project number (not project ID).
  5. In Role, select:
    • Cloud KMS CryptoKey Encrypter/Decrypter
      (roles/cloudkms.cryptoKeyEncrypterDecrypter)
  6. Click Save.
If you also use other Vertex AI features with CMEK, ensure any additional required service accounts have the same role.

3. Create a new Vertex AI dataset using CMEK

  1. In the console, go to: Vertex AIDatasets.
  2. Click Create (or + Create dataset).
  3. Choose the dataset type (e.g., Image, Tabular, Text, etc.), then click Next.
  4. Fill in:
    • Dataset name
    • Region: must match the region of your CMEK key (or a supported combination; ideally keep them the same).
  5. Look for Encryption or Customer-managed key (may appear under “Advanced options” or “Encryption” section):
    • By default, it’s Google-managed encryption key.
    • Change to Customer-managed key (CMEK).
  6. In the key selector:
    • Choose the Key ring.
    • Choose the Key you created in KMS.
  7. Complete the rest of the dataset creation flow:
    • Configure data source (e.g., GCS path).
    • Review settings.
    • Click Create.
The dataset will now be encrypted with your Customer-Managed Encryption Key.

4. Handling existing datasets

  • Existing Vertex AI datasets that were created without CMEK cannot be re-encrypted in place.
  • To “migrate” to CMEK:
    1. Create a new dataset following the CMEK steps above.
    2. Point it to the same source data in Cloud Storage or re-import your data.
    3. Update any jobs/pipelines/notebooks to use the new dataset.
    4. Decommission the old dataset when you’re done.

That’s all that’s required via the GCP Console: create/assign a KMS key, grant the Vertex AI service agent permissions, and select that key when creating new Vertex AI datasets.
Below are step‑by‑step CLI instructions to enforce Customer‑Managed Encryption Keys (CMEK) for Vertex AI datasets.

1. Set environment variables


2. Create (or ensure you have) a KMS key

If you do not have an existing key:
Full key resource name:

3. Grant Vertex AI service account access to the key

Determine your project number and the Vertex AI service account:
Grant KMS permissions:

4. Create a new Vertex AI dataset with CMEK

CMEK must be set at dataset creation time; you cannot retroactively add CMEK to an existing dataset. You’ll need to create new datasets with the CMEK key.Example: create an empty tabular dataset:
For other dataset types, change --metadata-schema-uri accordingly (image, text, etc.).

5. (Optional) Import data into the CMEK‑protected dataset

Example for a tabular CSV in Cloud Storage:

6. (Optional) Migrate from non‑CMEK datasets

  1. Export or re‑locate your raw data to Cloud Storage (if needed).
  2. Create a new CMEK dataset as in step 4.
  3. Import the data into the new dataset (step 5).
  4. Update any pipelines or models to use the new dataset ID.
  5. Delete the old non‑CMEK dataset when no longer needed:
This ensures all new Vertex AI datasets are encrypted with your Customer‑Managed Encryption Key.
Below is a concise, step‑by‑step guide to ensure Vertex AI datasets use Customer‑Managed Encryption Keys (CMEK) with Python.
Note: CMEK must be specified at dataset creation time. You cannot change the encryption key of an existing Vertex AI dataset; you must recreate the dataset with CMEK.

1. Prerequisites

  • gcloud installed and configured.
  • Python 3.7+.
  • Libraries:
  • Environment:

2. Create a CMEK key in Cloud KMS

The key resource ID will be:

3. Grant Vertex AI service account access to the key

Vertex AI uses a service agent like:
Find your project number:
Then grant it roles/cloudkms.cryptoKeyEncrypterDecrypter:

4. Python: Initialize Vertex AI with CMEK

Setting encryption_spec_key_name in aiplatform.init() makes this the default CMEK for subsequent resources created in this context (including datasets).

5. Create a dataset using CMEK (Python)

Example: Tabular dataset from BigQuery

Example: Image dataset from GCS


6. Verify the dataset is using CMEK

You should see the kms_key_name set to your CMEK key.

7. Handling existing datasets (misconfiguration)

Since CMEK cannot be retroactively applied:
  1. Export or re-point your data source (e.g., BigQuery table or GCS paths).
  2. Recreate the dataset with CMEK as shown above.
  3. Update any pipelines/models/jobs to use the new dataset.
  4. Delete the old non‑CMEK dataset if no longer needed.
Changing or adding encryption_spec.kms_key_name on an existing google_vertex_ai_dataset forces replacement of the dataset resource; this may be disruptive and data may need to be re-imported, so plan carefully.To verify, run terraform plan and confirm it shows either:
  • creation of a new google_vertex_ai_dataset with encryption_spec.kms_key_name set to your CMEK, or
  • a -/+ replacement of the existing dataset where the new resource includes encryption_spec.kms_key_name.