Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

VM Instance Image

Hi

I have a project with a vm instance running wordpress.

I create an image of that instance.

I created another project and gave the @cloudservice user from the new project access to the old project by adding it in the IAM/Roles first as a ComputeImageUser and next as Owner.

I tried to create a VM from Image in the new project,but the Image still Not showing in the new project.

Any idea why and how to solve this? Preferably using the Console not the Command prompt.

Thanks 

10 REPLIES 10

If we don't get any other answers, I'd suggest describing the puzzle in a public Google Doc with public commenter access which would include text and screen shots showing the whole story.  Then you can post back the link and we can see in more detail.  Make sure not to include anything sensitive .. mask out details as needed as this is a public forum.

To view the source OS image or source disk image of a VM, use the Google Cloud console, Google Cloud CLI, or Compute Engine API.  

Permission required for this task 

To perform this task, you must have the following permissions: 

- compute.instances.get on the instance 

Google Console API 

  1. In the Google Cloud console, go to the VM Instances page. 

Go to VM instances 

  1. Click the Name of the VM. 
  2. The name of the source OS image or source disk image is in Storage>Boot disk>Image. 

I can see the Image under Virtual Machines/Machine Images.

But only in the old project, I cant see it in the new project even though I added the Service account in the Roles of the old project.

So why the new project still doesn't have access to this Machine Image?

 

Basically, this what i m trying to do

https://cloud.google.com/deployment-manager/docs/configuration/using-images-from-other-projects-for-...

Let's say i have old project with id 738 & new project with id 236

I added the user below from the new project in the Roles of the old project.

[PROJECT_NUMBER]@cloudservices.gserviceaccount.com

 It says Policy was Updated.

However,when i click on Compute Engine--> Machine Images, when I click on the image it shows in Service accounts one service account,from the old project.

When I try to create a VM Instance from an Image,in the old project it shows the image, in the new project it says "You dont have any machine images".

When I click on Compute Engine--> Machine Images, in the old project, I can see the image i created and i can use it to create an instance.

Bottom line,how can i move/copy/grant access to the new project so i can do the same?

 

Perhaps this recipe gives you what you need.  I am imagining that you have a GCP Compute Engine (CE-1) in one project (P1) and you want to create a new Compute Engine (CE-2) in project (P2) using the disk image from the original Compute Engine (CE-1) as the base image.

https://cloud.google.com/compute/docs/instances/copy-vm-between-projects

Same issue,I can see the sanpshot in old project but not new one.

I tried the Test changes after adding the Roles,it says Policy Updated,but it shows that NO permissions were added.

The two projects have the same gmail account as the owner.

Is it possible it's not working because the projects are in two different zones?please tell me I can access resources even if they are in different zones.

Screenshot_20220619-161419_Brave~2.jpg

Screenshot_20220619-161721_Brave~2.jpg

Screenshot_20220619-161238_Brave~2.jpg

Reading here ... https://cloud.google.com/compute/docs/disks

I read about two types of persistent disks:

  • Zonal persistent disks - reside in one zone.  If the zone is lost, you can't access your data
  • Regional persistent disks - reside in two zones in a region.  If one zone is lost, you can still access your data from the other zone.  You can't use regional disks as boot disks.

However, under restrictions ... I also read:

  • You cannot attach a persistent disk to an instance in another project.

That last one is likely the root of your issues.  If I read it correctly, you can't access a bootable zonal persistent disks created in one project from another project.  What I think you can do is make a complete and distinct copy of the original disk and create a new disk from the original/copy.

Thanks.

The Problem is whatever copy i m making from the old project is not being seen in the new project.

Whoever designed the user experience of moving/copying a backup between 2 projects in the same account to be that complicated,they must have their head so far up their ass they cant see the sun.

Hi, if I can add some suggestions, just some ideas that you might find helpful.

Typically in the UI of the console what you see is scoped to the project you currently have selected, which is why you don't see machine images in other projects, despite having permission.

If you want to use 'machine-images' (and note these are different to custom images, see: https://cloud.google.com/compute/docs/machine-images for a nice comparison table) to move/copy VMs between projects.  Then you could do one of two things, both require a little use of the "gcloud" command line tool, which is easily accessible from Cloud Shell - the icon ">_" in the top right of the UI in a browser.

These approaches assume your user you are logged into the console with has required access to both projects to access VMs as well as create VMs and machine-images.

Option 1. Create the machine-image in the 'new' project, sourcing the VM you want to copy in the 'old' project.  Once done, you will have a usable machine-image listed in the UI console of your 'new' project and you can provision a new VM (or several) from it in the usual way.  To create a machine image in your 'new' project referencing the VM in the 'old' project, open up Cloud Shell and run these two commands:

a. Get the source link of the VM you want to create an image for, running the following command will give you a self link URL we can use when we create the image in step b:

gcloud compute instances describe VMNAME --zone=ZONE --project=OLDPROJECT --format="value(selfLink)"

Replacing all the red items with the variables that relate to your environment.

b. Create a new machine-image in your new project referencing the URL above with the following:

gcloud compute machine-images create IMAGENAME --source-instance=SOURCE-VM-URL --project=NEWPROJECT

Again replacing the variables in red, using the source VM URL from step a.  

At this point you should have a machine-image in your 'new' project that you can provision new VMs from in the UI as normal.

Option 2. Alternatively, you can do the other way round, you can create the machine-image in your 'old' project, then create a new VM in the 'new' project referencing that image.  In this case you could create the image in the UI as you did previously, but you would need to use the "gcloud" command to provision the VM as follows:

a. Get the source link of the machine-image you want to use from the 'old' project (note you would have already needed to create it of course), similar to above, this will give you a self link URL we can give to the command when we create the VM to reference the image:

gcloud compute machine-images describe IMAGENAME --project=OLDPROJECT --format="value(selfLink)"

b. Create a new VM referencing that machine-image - note that this exact command may vary depending on what configuration you want to apply to the new VM - for example if you want to specify which network it should join, so this is just an example - which will use the 'default' network :

gcloud beta compute instances create NEWVMNAME --source-machine-image=SOURCE-IMAGE-URL --zone=ZONE --project=NEWPROJECT 

As above, replacing the variables in red with values that make sense for your environment and using the image URL from the first command.

Hope that gives some suggestions as to a route to take.  I think if you are more comfortable with the UI, then I would go option 1 - simply because there are many more options/variables when provisioning a VM, that it might be more convenient to use the UI for that, compared to the process to capture the VM image which is comparatively simple command.

Hope that helps,

Alex

 

Thanks.

They should have a "Shared Library" where resources/assets created by the same Owner email account are visible and accessible by all their projects.

That should save some time,efforts and probably even have lower impact on the environment.