Google Compute Engine : Use snapshot from another project?

Remis Haroon picture Remis Haroon · Apr 12, 2015 · Viewed 20.3k times · Source

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 project-1. Right now snapshot is not showing in the option. How can I import snapshot from one project to another?

Answer

chrispomeroy picture chrispomeroy · Apr 13, 2015

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 <project-id-of-project-2>
gcloud config list

(You should verify you are in project 2)

gcloud compute instances create <name of instance> --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.