Skip to main content

Triage and Remediation

Remediation

Using Console

Sure! Here are the step by step instructions to remediate the misconfiguration “SQL Instances Should Be Encrypted Using Customer Managed Keys (CMKs)” for GCP using GCP console:
  1. Open the GCP console and navigate to the Cloud SQL instances page.
  2. Select the SQL instance that you want to encrypt.
  3. Click on the “Edit” button at the top of the page.
  4. Scroll down to the “Encryption” section and select the option “Customer-managed key”.
  5. Choose the key ring and key that you want to use for encryption. If you don’t have a key, create one by clicking on the “Create” button.
  6. Click on the “Save” button to save the changes.
Once you have completed these steps, your SQL instance will be encrypted using the customer-managed key that you selected. It is important to note that this process requires the appropriate permissions to create and manage keys in your GCP project.

To remediate the misconfiguration of SQL instances not being encrypted using customer managed keys (CMKs) in GCP using GCP CLI, follow these steps:
  1. Open the Cloud Shell in the GCP console.
  2. Use the following command to list all the Cloud SQL instances in your project:
  3. Choose the instance that you want to encrypt and note down its instance name.
  4. Use the following command to encrypt the SQL instance using a customer-managed encryption key:
    Replace [INSTANCE_NAME] with the name of your SQL instance, [SIZE] with the desired storage size in GB, [STORAGE_TYPE] with the desired storage type, [NETWORK_NAME] with the name of the authorized network, [DATABASE_VERSION] with the desired database version, [DAY_OF_WEEK] with the preferred day of the week for maintenance, [HOUR_OF_DAY] with the preferred hour of the day for maintenance, [RELEASE_CHANNEL] with the preferred release channel for maintenance, and [KEY_NAME] with the name of the customer-managed encryption key.
  5. Once you have executed the command, the SQL instance will be encrypted using the customer-managed encryption key.
  6. Verify the encryption status of the SQL instance using the following command:
    You should see the encryptionKeyName property set to the name of your customer-managed encryption key.
By following these steps, you can remediate the misconfiguration of SQL instances not being encrypted using customer-managed keys (CMKs) in GCP using GCP CLI.
To remediate the misconfiguration of SQL instances not being encrypted using customer-managed keys (CMKs) in GCP, you can use the following steps:
  1. Create a new Cloud KMS key ring and key to use as the CMK. You can do this using the following Python code:
Replace project_id, location_id, key_ring_id, and crypto_key_id with your own values.
  1. Update the SQL instance to use the newly created CMK. You can do this using the following Python code:
Replace project_id, instance_id, location_id, key_ring_id, and crypto_key_id with your own values.
  1. Verify that the SQL instance is now using the CMK for encryption. You can do this using the following Python code:
Replace instance_name with your own value.These steps will remediate the misconfiguration of SQL instances not being encrypted using customer-managed keys (CMKs) in GCP.
Switching an existing google_sql_database_instance to use a CMK via disk_encryption_configuration.kms_key_name forces the instance to be destroyed and re-created, so plan for downtime and data migration before applying.Verification: terraform plan should show disk_encryption_configuration.kms_key_name set on the google_sql_database_instance (and a replacement of the instance if it already exists), plus creation of the KMS key and IAM binding if they are new.