1
votes

I am trying to move Cloud SQL from one subnet to another on my GCP project. Basically, I created a Cloud SQL instance, which used google managed service connection, and the IP range is allocated by Google default. Where I want to switch to my own CIDR I setup via managed service connections created.

I am following the steps from Changing the private IP address of an existing Cloud SQL instance Trying to switch to a temporary network/vpc before attaching back to my custom VPC with my own managed service connections.

$gcloud --project=myprj beta sql instances patch mydbid --network=tmp_vpc --no-assign-ip

The following message will be used for the patch API method. {"name": "mydbid", "project": "myprj", "settings": {"ipConfiguration": {"ipv4Enabled": false, "privateNetwork": "https://compute.googleapis.com/compute/v1/projects/myprj/global/networks/tmp_vpc"}}} ERROR: (gcloud.beta.sql.instances.patch) HTTPError 400: This operation is not valid for this instance.

1

1 Answers

1
votes

I am assuming you are using a Shared VPC.

Currently, it is not possible to assign a Private IP from a Shared VPC network to an existing Cloud SQL instance.

This operation is only possible when creating a new instance, as explained in the

Quick reference for Private IP topics

You can create Cloud SQL instances with private IP addresses in a Shared VPC network. However, you cannot assign a private IP address in a Shared VPC network to an existing Cloud SQL instance.

Here you can find a Feature Request opened for your use case.