How to move an instance between two projects in Google Cloud Platform?
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:
- stop VM if possible, or reduce number of writes by shutting down services if not
- go to Compute Engine -> Images
- select create
- choose the disk as source
- set any other properties you need
- 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]
There isn't any tool in GCP that allows migrating one Compute Engine instance from one project to another.
However, it is still possible to recreate one instance from one project to another, by creating a snapshot of the disk, creating a custom image, and create a new VM from it in the second project.
This article gives a nice step by step guide on how to do it.