More Info:
Ensure that SQL Instances Backend Type is Second Generation.Risk Level
MediumAddress
Operational MaturityCompliance Standards
- APRA CPS 234 (Australia)
- BSI C5 (Germany)
- Brazil LGPD
- CCPA / CPRA (California)
- CIS Critical Security Controls v8
- CMMC 2.0
- CSA Cloud Controls Matrix v4
- Cloudanix Best Practice
- DPDPA
- Digital Operational Resilience Act (EU)
- Essential 8
- ISO/IEC 27017
- ISO/IEC 27018
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIS2 Directive
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- SWIFT Customer Security Controls Framework
- Sarbanes-Oxley IT General Controls
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remediate the misconfiguration “SQL Instance Should Have Backend Type Second Generation” for GCP using GCP console, follow these steps:
- Log in to your GCP console.
- Go to the Cloud SQL Instances page.
- Select the SQL instance that you want to remediate.
- Click on the “Edit” button at the top of the page.
- Scroll down to the “Configuration options” section.
- Under the “Backend Type” option, select “Second Generation” from the dropdown menu.
- Click on the “Save” button at the bottom of the page.
- Wait for the changes to take effect. This may take a few minutes.
Using CLI
Using CLI
To remediate the misconfiguration “SQL Instance Should Have Backend Type Second Generation” for GCP using GCP CLI, follow these steps:Replace [INSTANCE_NAME] with the actual name of the SQL instance.This command should return a description of the SQL instance, which should include the “backendType” field set to “SECOND_GEN”.
- Open the Google Cloud Console and navigate to the Cloud Shell.
- Run the following command to list all the existing SQL instances:
- Identify the SQL instance that needs to be updated and note down its name.
- Run the following command to update the SQL instance with the Second Generation backend type:
- Wait for the update to complete. This may take a few minutes.
- Run the following command to verify that the SQL instance has been updated:
- Verify that your application is still functioning as expected.
Using Python
Using Python
To remediate the misconfiguration “SQL Instance Should Have Backend Type Second Generation” in GCP using Python, you can follow the below steps:
- First, you need to get a list of all the SQL instances in your GCP project using the Cloud SQL Admin API. You can use the following code to get the list of SQL instances:
- Once you have the list of SQL instances, you can loop through each instance and check if it has a backend type of “SECOND_GEN”. If not, you can update the instance’s backend type using the
patchmethod of the Cloud SQL Admin API. Here’s the code to do that:
- Finally, you can verify that the backend type of all the SQL instances has been updated to “SECOND_GEN” by re-running the code to get the list of instances and checking their backend types.
project parameter to your GCP project ID in the code.Using Terraform
Using Terraform
backend_type is a computed, read‑only field on google_sql_database_instance and cannot be changed from FIRST_GEN to SECOND_GEN in place; you must create a new Second Generation instance (as above) and migrate data (export/import, replica promotion, etc.), then remove the old FIRST_GEN instance from Terraform.This change forces replacement of the instance: terraform plan should show the old FIRST_GEN google_sql_database_instance being destroyed and the new Second Gen google_sql_database_instance.SECOND_GEN_INSTANCE being created (or a create-then-destroy sequence if create_before_destroy = true is used).
