Triage and Remediation
Remediation
Using Console
Using Console
To remediate the misconfiguration “Customer Supplied Encryption Key Should Be Enabled For Disks” for GCP using GCP console, please follow the below steps:
- Open the GCP Console and select the project for which you want to enable Customer Supplied Encryption Key.
- In the left navigation menu, select “Compute Engine” and then select “Disks”.
- Select the disk for which you want to enable Customer Supplied Encryption Key.
- Click on “Edit” at the top of the page.
- In the Encryption section, select “Customer-supplied encryption key”.
- Enter the 256-bit encryption key in the “Key” field.
- Click on “Save” to save the changes.
Using CLI
Using CLI
To remediate the “Customer Supplied Encryption Key Should Be Enabled For Disks” 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 check if the customer-supplied encryption key is enabled for the disks:
Replace [DISK_NAME] with the name of the disk that you want to check and [ZONE] with the zone in which the disk is located.
-
If the output of the previous command is “False”, then the customer-supplied encryption key is not enabled for the disk. To enable it, run the following command:
Replace [DISK_NAME] with the name of the disk that you want to encrypt and [ZONE] with the zone in which the disk is located. Replace [USER_EMAIL] with the email address of the user who will be able to encrypt and decrypt the disk.
-
After running the above command, the customer-supplied encryption key will be enabled for the disk. You can verify it by running the following command:
The output of the above command should be “True”, indicating that the customer-supplied encryption key is enabled for the disk.
Using Python
Using Python
To remediate the misconfiguration “Customer Supplied Encryption Key Should Be Enabled For Disks” in GCP using Python, you can follow the below steps:Step 1: Install the required packagesStep 2: Authenticate to GCPStep 3: Import the required librariesStep 4: Create a service account and grant it the required permissionsStep 5: Create a function to enable customer-supplied encryption key for disksStep 6: Call the function to enable customer-supplied encryption key for the diskNote: Replace the placeholders
<project-id>
, <zone>
, <instance-name>
, <disk-name>
, and <encryption-key>
with the actual values for your GCP project.