Triage and Remediation
Remediation
Using Console
Using Console
To remediate the “Dataflow Job CMK Keys Should Be Set” misconfiguration in GCP using the GCP console, please follow these steps:
- Open the Google Cloud Console and go to the Dataflow page.
- Select the Dataflow job that is affected by the misconfiguration.
- Click on the “Edit” button to edit the job configuration.
- Scroll down to the “Security” section of the configuration page.
- Under the “Encryption” section, select “Customer-managed key” from the “Key source” dropdown menu.
- Choose the appropriate Cloud KMS key that you want to use to encrypt your data.
- Click on the “Save” button to save the changes.
Using CLI
Using CLI
To remediate the “Dataflow Job CMK Keys Should Be Set” misconfiguration in GCP using GCP CLI, you can follow the below steps:
- Open the Cloud Shell in your GCP Console.
-
Run the following command to set the Cloud Key Management Service (KMS) key for Dataflow:
Replace
<JOB_ID>
with the ID of the Dataflow job and<KMS_KEY>
with the ID or fully qualified name of the Cloud KMS key to be used for encrypting the Dataflow job’s temporary files. -
Verify that the KMS key has been set by running the following command:
This command should return the name of the KMS key that was set in step 2.
- Repeat steps 2 and 3 for all Dataflow jobs that require a KMS key to be set.
Using Python
Using Python
To remediate the misconfiguration “Dataflow Job CMK Keys Should Be Set” for GCP using python, you can follow the below steps:By following these steps, you should be able to remediate the misconfiguration “Dataflow Job CMK Keys Should Be Set” for GCP using python.
- First, you need to create a Cloud KMS key ring and key in the same region as your Dataflow job. You can use the following code to create a key ring and key:
- Once you have created the key ring and key, you can update your Dataflow job to use the key. You can use the following code to update your job:
- Finally, you can verify that the job is using the Cloud KMS key by checking the logs. You should see a message similar to the following: