Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move an instance between two projects in Google Cloud Platform?

In compute engine, How can I move an instance from project A to project B?

I have two projects, and both have the same owner. I looked at all the interfaces inside the console, but I could not find a way.

like image 950
Salvino Avatar asked Feb 03 '19 08:02

Salvino


People also ask

How do I move a GCP project?

Click on your project's row to select your project from the list of resources. Note that you must not click on the name of the project, which takes you to the project's IAM page. Click on the options menu (the vertical ellipsis) in the row and click Move.

How do I change instances in Google Cloud?

In the Google Cloud console, go to the Filestore Instances page. Click the instance ID of the instance you want to edit. On the Instance details page, click Edit to go to the Edit instance page. Change the instance description, IP-based access control rules, and capacity as needed.

How do I copy instances to Google Cloud?

Click the VM Instance you want to clone. Click "Create Machine Image" at the top. From Machine Images on the left, open your new image and click "Create VM Instance"


1 Answers

This can be done fairly easily now, with the caveat that when you create the VM in the other project it cannot be done through the UI but rather must be done using the gcloud tool. And google even has a page to document how.

First, you need to either create an image or a snapshot of the disk used in the VM. You can do this through the Console UI or the gcloud utility. Google's documentation does a good job of explaining how to do it, but the TLDR is:

  1. stop VM if possible, or reduce number of writes by shutting down services if not
  2. go to Compute Engine -> Images
  3. select create
  4. choose the disk as source
  5. set any other properties you need
  6. press create

Once that has been completed, use the gcloud tool with the other project to create your new VM. To find out/verify the name of the disk image:

gcloud compute images list --project [IMAGE_PROJECT]

then create the vm (add any additional options you need):

gcloud compute instances create [INSTANCE_NAME] --image [IMAGE_NAME] --image-project [IMAGE_PROJECT]
like image 133
rmtmckenzie Avatar answered Oct 07 '22 20:10

rmtmckenzie