Google Compute Engine : Use snapshot from another project?

前端 未结 7 1405
别那么骄傲
别那么骄傲 2020-12-13 10:07

I have two projects in my developer console. I have taken a \"Snapshot\" of one of the VMs in project-1. I want to create a new VM in project-2 using the snapshot created in

7条回答
  •  时光取名叫无心
    2020-12-13 10:54

    You can create an image from the snap in Project 1, then create an instance from that image using Project 2.

    I'm assuming you have edit rights in both projects.

    Your question says you have a snapshot and want to make an instance in project 2 from the snap in project 1.

    If you still have the disk available that you had snapshotted, make sure it's no longer attached to an instance. If it's still attached to the instance, uncheck "delete boot disk when deleting instance" and delete the instance. Go to Images and click create image from disk, and create an image from this disk.

    If you do not have the disk available, but just the snapshot, create an instance and set the boot disk as a snapshot and select your snapshot. Then follow the directions above to create an image by deleting the instance first.

    Now you have an image in project 1. You should see it listed under images.

    I'm not sure why, but you won't see the image listed in the console in project 2, however you can use gcloud to create an instance in project 2 using the image from project 1. In project 1, click on the image and click "view REST" there will be a full URL to the image, similar to this:

    https://www.googleapis.com/compute/v1/projects/cpomeroy-whitelist/global/images/ruby-image
    

    Use gcloud to create an instance in project 2 using the image in project 1:

    gcloud config set project 
    gcloud config list
    

    (You should verify you are in project 2)

    gcloud compute instances create  --image https://www.googleapis.com/compute/v1/projects/cpomeroy-whitelist/global/images/ruby-image
    

    Obviously your URL will be different.

    I just tested this and it works. Let me know if you need more help.

提交回复
热议问题