Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change the network of an existing Google Compute Engine VM

I have a couple of Google Compute Engine (GCE) virtual machines spread across two GCE networks. Now I want to move them all to one shared network but I can't find a way to change the network of an existing VM. Is there a way to do this or do I have to recreate the VMs in the new network?

like image 851
Fabian Jakobs Avatar asked Jan 16 '14 15:01

Fabian Jakobs


2 Answers

You have to recreate the VM's in the new network.

like image 148
Brian Dorsey Avatar answered Sep 23 '22 11:09

Brian Dorsey


Google Developers Console

Although you cannot directly move an instance, the Google Developers Console now has the function to Clone this instance. Go to Google Developers Console, navigate to Project ID -> Compute Engine -> VM Instances -> . Scroll down to the end and you should see the option

Google Cloud Console

After clicking on Clone this instance, you will be brought to the new instance creation page, with an option to select which Zone you wish to clone the target instance.

Create new instance


gcutil

You can use the gcutil moveinstances command to move an instance from a zone to another zone. You can even move a list of instances using regular expression, for example:

gcutil moveinstances --source_zone=zone-a
                             --destination_zone=zone-b "i-[0-9]" "b-.*"

For more information, type gcutil help moveinstances

like image 43
Hanxue Avatar answered Sep 21 '22 11:09

Hanxue