Triage and Remediation
Remediation
Using Console
Using Console
To remediate the misconfiguration “Keys Should Be Managed By Google” in GCP, follow the below steps using GCP console:
- Open the GCP Console and navigate to the project for which you want to remediate the misconfiguration.
- Click on the “IAM & Admin” option in the left-hand menu.
- Click on the “Service Accounts” tab.
- Select the service account for which you want to remediate the misconfiguration.
- Click on the “Edit” button at the top of the page.
- Scroll down to the “Keys” section.
- Click on the “Delete” button next to any existing keys that are not managed by Google.
- Click on the “Create Key” button.
- Select the “JSON” key type.
- Click on the “Create” button.
Using CLI
Using CLI
The “Keys Should Be Managed By Google” misconfiguration in GCP means that there are service account keys being used that are not managed by Google. To remediate this issue, you can follow these steps using the GCP CLI:Note: Replace [SERVICE-ACCOUNT-EMAIL] with the email address of the service account that you want to check.Note: Replace [KEY-ID] with the ID of the non-managed key and [SERVICE-ACCOUNT-EMAIL] with the email address of the service account that you want to delete the key from.Note: Replace [KEY-NAME] with a name for the new key, [SERVICE-ACCOUNT-EMAIL] with the email address of the service account that you want to enable automatic rotation for, and adjust the rotation period and next rotation time to meet your requirements.By following these steps, you can remediate the “Keys Should Be Managed By Google” misconfiguration in GCP using the GCP CLI.
- Identify the service account keys that are not managed by Google:
- Delete the non-managed service account keys:
- Enable automatic rotation of service account keys:
Using Python
Using Python
To remediate the “Keys Should Be Managed By Google” misconfiguration for GCP using Python, you can follow these steps:
-
Install the Google Cloud SDK and authenticate to your GCP project using the command
gcloud auth login
. -
Install the
google-cloud-iam
Python library using the commandpip install google-cloud-iam
. -
Write a Python script that uses the
google-cloud-iam
library to remove any non-Google-managed service account keys. Here’s an example script:
- Run the Python script using the command
python script.py
. This will remove any non-Google-managed service account keys in your GCP project.