Overview
It is recommended to configure Second Generation Sql instance to use private IPs instead of public IPs.
Rationale
To lower the organization's attack surface, Cloud SQL databases should not have public IPs. Private IPs provide improved network security and lower latency for your application.
Impact
Removing the public IP address on SQL instances may break some applications that relied on it for database connectivity.
Remediation guidance
From Google Cloud Console
- Go to the
Cloud SQL Instancespage in the Google Cloud Console by visiting https://console.cloud.google.com/sql/instances - Select the instance name to open its
Overviewpage - Navigate to
Connections, and then toNETWORKING - Deselect the
Public IPcheckbox - Click
Save
From Google Cloud CLI
- For every instance, remove its public IP and assign a private IP instead:
gcloud sql instances patch <instanceName> --network= --noassign-ip
- Confirm the changes using the following command:
gcloud sql instances describe <instanceName>
Prevention
To prevent new SQL instances from getting configured with public IP addresses, set up a Restrict Public IP access on Cloud SQL instances Organization policy at: https://console.cloud.google.com/iam-admin/orgpolicies/sql-restrictPublicIp.
Default Value
By default, Cloud Sql instances have a public IP.
References
- https://cloud.google.com/sql/docs/mysql/configure-private-ip
- https://cloud.google.com/sql/docs/mysql/private-ip
- https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints
- https://console.cloud.google.com/iam-admin/orgpolicies/sql-restrictPublicIp
Addititonal information
Replicas inherit their private IP status from their primary instance. You cannot configure a private IP directly on a replica.
Multiple Remediation Paths
Google Cloud
SERVICE-WIDE (RECOMMENDED when many resources are affected): Enforce Organization Policies at org/folder level so new resources inherit secure defaults.
gcloud org-policies set-policy policy.yaml
ASSET-LEVEL: Use the product-specific remediation steps above for only the impacted project/resources.
PREVENTIVE: Use org policy constraints/custom constraints and enforce checks in deployment pipelines.
References for Service-Wide Patterns
- GCP Organization Policy overview: https://cloud.google.com/resource-manager/docs/organization-policy/overview
- GCP Organization policy constraints catalog: https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints
- gcloud org-policies: https://cloud.google.com/sdk/gcloud/reference/org-policies
Operational Rollout Workflow
Use this sequence to reduce risk and avoid repeated drift.
1. Contain at Service-Wide Scope First (Recommended)
- Google Cloud: apply organization policy constraints at org/folder scope.
gcloud org-policies set-policy policy.yaml
2. Remediate Existing Affected Assets
- Execute the control-specific Console/CLI steps documented above for each flagged resource.
- Prioritize internet-exposed and production assets first.
3. Validate and Prevent Recurrence
- Re-scan after each remediation batch.
- Track exceptions with owner and expiry date.
- Add preventive checks in IaC/CI pipelines.
Query logic
These are the stored checks tied to this control.
Cloud SQL database instances do not have public IPs
Connectors
Covered asset types
Expected check: eq []
{cloudSqlInstances(where:{instanceType:"CLOUD_SQL_INSTANCE",backendType:"SECOND_GEN",ipAddresses_SOME:{type:"PRIMARY"}}){...AssetFragment}}
Google Cloud