Customer-managed encryption keys (CMEK) provide user control over the data written by Cloud Data Fusion pipelines, including:
- Dataproc cluster metadata
- Cloud Storage, BigQuery, and Pub/Sub data sources and sinks
This page describes how to use a Cloud Key Management Service (Cloud KMS) encryption key with Cloud Data Fusion. A customer-managed encryption key (CMEK) enables encryption of data at rest with a key that you can control through Cloud KMS. You can create a pipeline that is protected with a CMEK or access CMEK-protected data in sources and sinks.
Cloud Data Fusion resources
Cloud Data Fusion supports customer-managed encryption keys (CMEK) for the following Cloud Data Fusion plugins:
Cloud Data Fusion sinks:
- Cloud Storage
- Cloud Storage multi-file
- BigQuery
- BigQuery multi-table
- Pub/Sub
Cloud Data Fusion actions:
- Cloud Storage create
- BigQuery execute
Cloud Data Fusion supports customer-managed encryption keys (CMEK) for Dataproc clusters. Cloud Data Fusion creates a temporary Dataproc cluster for use in the pipeline, which is deleted when the pipeline completes. CMEK protects the cluster metadata written to the following:
- Persistent disks (PDs) attached to cluster VMs.
- Job driver output and other metadata written to the auto-created or user-created Dataproc staging bucket.
Set up CMEK
Get the resource ID of the key that you created, which you use later in this procedure.
projects/project-id/locations/region/keyRings/key-ring-name/cryptoKeys/key-name
- In the Cloud Console, go to the Cryptographic Keys page.
- Click the three-dot menu next to your key.
- Click Copy Resource ID. This copies your resource ID to the clipboard.
Set up your project's service accounts to use your key:
- Required: You must grant the
Cloud KMS CryptoKey Encrypter/Decrypter role
to the Compute Engine System service account
(see Granting roles to a service account for specific resources). This account,
which by default is granted the Compute Engine Service Agent role,
is of the form:
service-[PROJECT_NUMBER]@compute-system.iam.gserviceaccount.com
- Required: You must grant the
Cloud KMS CryptoKey Encrypter/Decrypter role
to the Cloud Storage service agent
(see Assigning a Cloud KMS key to a Cloud Storage service agent).
This service agent is of the form:
service-[PROJECT_NUMBER]@gs-project-accounts.iam.gserviceaccount.com
- Optional: If your pipeline uses BigQuery resources,
grant the Cloud KMS CryptoKey Encrypter/Decrypter role
to the BigQuery service account
(see Grant encryption and decryption permission).
This account is of the form:
bq-[PROJECT_NUMBER]@bigquery-encryption.iam.gserviceaccount.com
- Optional: If your pipeline uses Pub/Sub resources, grant
the
Cloud KMS CryptoKey Encrypter/Decrypter role
to the Pub/Sub service account
(see Using customer-managed encryption keys).
This account is of the form:
service-[PROJECT_NUMBER]@gcp-sa-pubsub.iam.gserviceaccount.com
- Required: You must grant the
Cloud KMS CryptoKey Encrypter/Decrypter role
to the Compute Engine System service account
(see Granting roles to a service account for specific resources). This account,
which by default is granted the Compute Engine Service Agent role,
is of the form:
Use CMEK with Dataproc cluster metadata
To use CMEK to encrypt PD (Persistent Disk) and the staging bucket metadata written by the Dataproc cluster running in your pipeline, do one of the following:
- Recommended: Create a Dataproc compute profile (Enterprise edition only).
- Edit an existing Dataproc compute profile (Developer, Basic, or Enterprise edition).
- Open the Cloud Data Fusion Instances page in the Cloud Console.
- In the Actions column for the instance, click View Instance.
- In the Cloud Data Fusion web UI, click SYSTEM ADMIN.
- Click the Configuration tab.
- Click the System Compute Profiles drop-down.
- Click Create New Profile.
- Select Cloud Dataproc.
- Enter a Profile label, Profile name, and Description.
- By default, Cloud Data Fusion auto-creates a Cloud Storage
bucket to be used as the Dataproc staging bucket.
If you prefer to use a Cloud Storage bucket that already exists in
your project, follow these steps:
- In the General Settings section, enter your existing Cloud Storage bucket in the Cloud Storage Bucket field.
- Add your Cloud KMS key to your Cloud Storage bucket.
- Get the resource ID of your Cloud KMS key. In the General Settings section, enter your resource ID in the Encryption Key Name field.
- Click Create.
- If more than one profile is listed in the System Compute Profiles
section of the Configuration tab, make the new
Dataproc profile the default profile by holding the
pointer over the profile name field and clicking the star that appears.
Use CMEK with other resources
To use CMEK to encrypt data written by other resources, such as Cloud Storage, BigQuery, or Pub/Sub sinks, do one of the following:
- Use a runtime argument.
- Set a Cloud Data Fusion system preference.
Runtime argument
- In the Cloud Data Fusion Pipeline Studio page, click the drop-down arrow to the right of the Run button.
- In the Name field, enter
gcp.cmek.key.name
. - In the Value field, enter your key's resource ID.
- Click Save.
Preference
- In the Cloud Data Fusion UI, click SYSTEM ADMIN.
- Click the Configuration tab.
- Click the System Preferences drop-down.
- Click Edit System Preferences.
- In the Key field, enter
gcp.cmek.key.name
. - In the Value field, enter your key's resource ID.
- Click Save & Close.