Search code examples
google-cloud-platformgoogle-cloud-sdk

GCP - moving VMs across projects with the Google Cloud SDK


I want to move some VMs across projects on GCP using the Cloud SDK.

I'd like the process on a high level, and then possibly also some links out to the relevant docs, although I can RTFM when I know what the general high-level steps are.

I think what I want to do is

  1. Create a snapshot
  2. Save it somewhere
  3. Create two Cloud SDK contexts?
  4. Prepare a destination in the context for the new project
  5. Copy the snapshots over to the new context and its associated storage
  6. Rehydrate from the copied snapshot in the new project once everything is copied.

Please help. I'm new with this stuff and want to know whether this is really how it should be done.

Thanks!


Solution

  • You can use this guide

    Quick summary of steps needed

    1. Detach the boot disk from the VM that you intend to move by deselecting “Delete boot disk on instance delete” and terminating the VM

    2. Create an image from the detached boot disk

    3. Upload the image to Google Cloud Storage and share it with the new project

    4. Create a custom image under the new project based on the image you uploaded to Google Cloud Storage

    5. Create a new VM instance under the new project based on the custom image