Search code examples
postgresqlgoogle-cloud-platformgoogle-cloud-sql

Creating a SQL instance on GCP and setting Private services access?


I`m setting up a SQL instance on GCP, when configuring the options I want to choose a network path for connecting to this instance. I want to choose private IP:

enter image description here

So I`m trying to set up the private IP connection :

enter image description here

Choose default-ip-range:

enter image description here

And get the error:

enter image description here

So I tried to set up a manual connection with:

enter image description here enter image description here

And again the error:

enter image description here

So I tried option use automatically allocated IP range and it just wants to reconnect to the existing dafeault_ip_range and I get the error: The resource 'projects/[myProject]/global/addresses/default-ip-range' already exists

Don't know what else to try...


Solution

  • There are two ways to fix this issue. Either way, the objective is to allocate the respective IP ranges to the private connection.

    First, using CLI Command, which will call update connection with new ranges and force flag to change the ranges used for the connection:

    gcloud services vpc-peerings update --network=default --ranges=new-ip-range-4,default-ip-range --service=servicenetworking.googleapis.com --force
    

    Or second, navigate to Google Cloud Platform > VPC Network > VPC Network Details > Private Service Connection > Private Connections to Services. Modify the private connection with the desired IP ranges

    For example in the UI, it should look like thisenter image description here