Description
Cloud SQL public addressing and network admission are separate settings. An authorized range of 0.0.0.0/0 permits direct connection attempts from any IPv4 address. An IAM-authorized Cloud SQL Auth Proxy can use public or private IP without an authorized-network entry.
Potential impact
A broad range admits unnecessary login attempts. A wrong range can block the application. Reading or changing data also requires database authentication and permissions.
Remediation
Choose the network path and connection method first. For private-only access, establish and test the private path before disabling public IP. In settings.ip_configuration, allow only verified client addresses for direct connections that require an authorized network. Check the deployed IP settings, database authentication, permissions and TLS, and test the application’s connection.
IP configuration examples
Supply resource_name, the project ID and the path to the service account JSON file. The network labels in these tasks are examples.
Connection settings to review
- name: sql_instance
google.cloud.gcp_sql_instance:
auth_kind: serviceaccount
name: "{{ resource_name }}-2"
project: test_project
region: us-central1
service_account_file: /tmp/auth.pem
settings:
ip_configuration:
authorized_networks:
- name: "google dns server"
value: "0.0.0.0"
tier: db-n1-standard-1
state: present
- name: sql_instance2
google.cloud.gcp_sql_instance:
auth_kind: serviceaccount
name: "{{ resource_name }}-2"
project: test_project
region: us-central1
service_account_file: /tmp/auth.pem
settings:
ip_configuration:
ipv4_enabled: yes
tier: db-n1-standard-1
state: present
A single-address entry
- name: sql_instance
google.cloud.gcp_sql_instance:
auth_kind: serviceaccount
name: "{{ resource_name }}-2"
project: test_project
region: us-central1
service_account_file: /tmp/auth.pem
settings:
ip_configuration:
authorized_networks:
- name: app-admin-host
value: 8.8.8.8/32
tier: db-n1-standard-1
state: present
Explanation:
- Connection settings to review:
0.0.0.0is a single address, not the all-IPv4 CIDR0.0.0.0/0. The second task enables a public IPv4 address without listing authorized networks. That alone does not admit direct connections from everyone. - A single-address entry:
8.8.8.8/32identifies Google Public DNS. Replace it with the verified address of the intended client, regardless of theapp-admin-hostlabel.