How to change Region / Zone in Google Cloud?

Viewed 63399

I am very new to Google Cloud. I was able to setup a wordpress site and am working on it now. However, it appears that my vm instance is using the following asia-east1-a for its zone. I was able to change the Region and Zone using gcloud commands with the following output:

$ gcloud config list compute/region 
Your active configuration is: [default]
[compute]
region = us-east4

$ gcloud config list compute/zone
Your active configuration is: [default]
[compute]
zone = us-east4-b

How does one change the active default to the new set zone? I would like my instance to run in the North East Coast of the USA?

Thanks, T

5 Answers

Use commands below at cloud shell.

To check your preferred region:

$ gcloud compute regions list

To change compute regions, I select us-east4 region:

$ gcloud config set compute/region us-east4

Updated property [compute/region].

$ gcloud config list compute/region 

[compute]

region = us-east4

In a similar way, you can change compute/zone.

If you don't remember the specific commands, another option is to change the region and zone in the gcloud configurations file which is located in:

~/.config/gcloud/configurations/config_default

And contain the structure below:

[core]
account = my-account@my-domain
project = my-project

[compute]
zone = asia-south1-a
region = asia-south1

After changing region to us-central-1 you'll get the following output:

gcloud config list compute/region
[compute]
region = us-central1

gcloud config configurations list
NAME     IS_ACTIVE  ACCOUNT               PROJECT     COMPUTE_DEFAULT_ZONE  COMPUTE_DEFAULT_REGION
default  True       my-account@my-domain  my-project  us-central1-a         us-central1

Reference to all GCP regions and zones.

Create Image of the existing instance and after create a new instance with a new zone who you like and uploaded this image with you create before

gcloud compute instances move INSTANCE_NAME --destination-zone=DESTINATION_ZONE [--async] [--zone=ZONE] [GCLOUD_WIDE_FLAG …]

gcloud compute instances move facilitates moving a Compute Engine virtual machine from one zone to another.

EXAMPLE :

gcloud compute instances move compute-instance-1 --zone us-central1-b --destination-zone us-central1-f
Related