Triage and Remediation
Remediation
Using Console
Using Console
To detect KMS keys that are scheduled to be destroyed in GCP, follow these steps:
- Open the Google Cloud Console and select the project where the KMS key is located.
- In the left-hand menu, select “Security”.
- Click on “Key Management Service”.
- In the KMS dashboard, click on “Scheduled for destruction” in the left-hand menu.
- You will see a list of KMS keys that are scheduled for destruction.
- Select the KMS key that is scheduled for destruction.
- Click on “Cancel destruction” in the top menu.
- Confirm the cancellation.
- Click on “Create key” in the top menu.
- Choose the key type and key version.
- Enter a name for the key.
- Click on “Create”.
Using CLI
Using CLI
To detect KMS keys that are scheduled to be destroyed in GCP, you can use the following steps:Replace [KEY-NAME] with the name of the key that you want to remediate.
- Open the Cloud Shell in your GCP console.
- Run the following command to list all the KMS keys that are scheduled for destruction:
- This command will return a list of all the KMS keys that are scheduled for destruction. Note down the name of the key that you want to remediate.
- To cancel the scheduled destruction of the key, run the following command:
- This command will cancel the scheduled destruction of the key and the key will be available for use again.
- Verify that the key is no longer scheduled for destruction by running the first command again.
Using Python
Using Python
To detect KMS keys that are scheduled to be destroyed in GCP using Python, you can use the Google Cloud KMS API. Here are the steps to remediate this issue:
- First, you need to authenticate and authorize your application to access the Google Cloud KMS API. You can use a service account key file for this purpose. You can create a service account and download the key file from the Google Cloud Console.
-
Install the Google Cloud KMS API client library for Python using pip:
-
Use the following Python code to detect KMS keys that are scheduled to be destroyed:
-
Once you have identified the KMS keys that are scheduled to be destroyed, you can either cancel the destruction or rotate the keys to new ones. Here are the steps for each option:
-
To cancel the destruction, use the following Python code:
-
To rotate the keys to new ones, use the following Python code:
-
To cancel the destruction, use the following Python code: