Triage and Remediation
Remediation
Using Console
Using Console
To remediate the misconfiguration “Legacy Networks Should Not Be Used” in GCP using GCP console, follow the below steps:
- Open the GCP console and go to the VPC networks page.
- Select the legacy network that you want to remediate.
- In the top menu, click “Delete”.
- Review the list of resources that will be deleted with the legacy network. If you are sure you want to delete the legacy network and all its resources, click “Delete”.
- Repeat this process for all legacy networks in your GCP project.
- Open the GCP console and go to the VPC networks page.
- Click “Create VPC network”.
- Enter a name for the new VPC network.
- Choose a subnet mode and specify the IP range for the new VPC network.
- Click “Create”.
- Migrate your resources to the new VPC network by updating their network settings to use the new VPC network.
Using CLI
Using CLI
To remediate the “Legacy Networks Should Not Be Used” misconfiguration in GCP using GCP CLI, follow these steps:
- Open the GCP Cloud Shell by clicking on the Activate Cloud Shell button on the top right corner of the GCP Console.
-
Run the following command to list all the VPC networks in your project:
- Identify the legacy network(s) in the list. Legacy networks are identified by the “LEGACY” network type.
-
Delete the legacy network(s) using the following command:
Replace [LEGACY_NETWORK_NAME] with the name of the legacy network you want to delete.
- Confirm the deletion by typing “y” when prompted.
Using Python
Using Python
To remediate the misconfiguration “Legacy Networks Should Not Be Used” in GCP using Python, you can follow the below steps:Step 1: Install the required packages:Step 2: Authenticate with GCP using the below command:Step 3: Write a Python script to remediate the misconfiguration:Step 4: Replace “your-project-id” and “your-region” with your actual project ID and region where the legacy networks are located.Step 5: Run the Python script to delete all the legacy networks in the specified project and region.Note: Before deleting any network, make sure that it is not being used by any resources in your project.