Search code examples
google-cloud-platformgoogle-cloud-sqlgcloud

What is the reason for error "Resource in project is the subject of a conflict" while trying to recreate a cloudsql instance?


I am trying to create a cloudsql instance with the following command:

gcloud beta sql instances create sql-instance-1 --tier=db-f1-micro --region=asia-south1 --network=default --storage-type=HDD --storage-size=10GB --authorized-networks=XX.XXX.XX.XX/XX

The instance sql-instance-1 is something I need not running all the time. So I create an sqldump file and when I need the database I create it. When I run this command it fails with the following error

ERROR: (gcloud.beta.sql.instances.create) Resource in project [my-project-id] is the subject of a conflict: The instance or operation is not in an appropriate state to handle the request.

From what I understand the gcloud is complaining that instance name was used before although the instance is already deleted. When I change the name to a new unused name the command works fine. The problem with this is I need to give a new name every time I re-create the instance from the dump.

My questions are:

  • Is this expected behavior i.e. should name of cloud-sql instance be unique and not used before within a project.
  • I also found that --network option is not recognized with gcloud. Seems to work only with gcloud beta as explained here. When is this expected to become GA?

Solution

  • This is indeed expected behaviour. From the documentation:

    You cannot reuse an instance name for up to a week after you have deleted an instance.

    Regarding the --network flag and it's schedule for GA, there is no ETA for its release outside of beta. However, it's release will be listed in the Google Cloud SDK Release Notes, which you can get updates from by subscribing to the google-cloud-sdk-announce group