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

后端 未结 2 1963
半阙折子戏
半阙折子戏 2021-01-04 09:52

In computer 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

相关标签:
2条回答
  • 2021-01-04 10:33

    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]
    
    0 讨论(0)
  • 2021-01-04 10:51

    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.

    0 讨论(0)
提交回复
热议问题