We are facing an error when we try to change the PostgreSQL instance availability type from regional to zonal.
Error: Error when reading or editing SQL User yyy@zzz.com in instance <project id>
googleapi: Error 400: Invalid request: Invalid request since instance is not running.
An instance has been stopped by us to change the availability type.
@kumards
The error you're encountering is due to the fact that the PostgreSQL instance needs to be stopped in order to change its availability type. When the instance is running, you cannot make this specific configuration change.
Here’s how you can resolve this:
Stop the PostgreSQL Instance:
You need to stop the instance before changing the availability type. You can do this via the Google Cloud Console, gcloud
command line, or the API.
Using gcloud command:
gcloud sql instances patch <instance-id> --activation-policy=NEVER
Or stop the instance from the Console:
Change the Availability Type:
Once the instance is stopped, you can proceed to change the availability type from regional to zonal.
Using gcloud command:
gcloud sql instances patch <instance-id> --availability-type=ZONAL
Or from the Console:
Start the PostgreSQL Instance:
After the availability type change is complete, start the instance again.
Using gcloud command:
gcloud sql instances patch <instance-id> --activation-policy=ALWAYS
Or from the Console:
This sequence ensures that the availability type change is applied correctly.
Doesn't the error clearly say the instance is not running? They also included a comment to confirm this:
An instance has been stopped by us to change the availability type.