2
votes

I am creating a copy of a VM(Compute Engine) from one project to another project, by taking a image of the boot disk and create a new instance using the image. I want to export and import the VM's other info as well, like Tags, machine-type, zone, scope etc.

I am using gcloud console scripts to take images & creating VMs etc, since I have to migrate/copy many VMs at a time.

Please suggest a way to import/export Tags, machine-type, zone, scope etc.

2

2 Answers

1
votes
  1. Gather the data via API or gcloud compute command before you tear down the old instances
  2. Provide that information via API or gcloud compute command at creation-time or configure the instances subsequent to creation
  3. Enjoy your clones

The gathering and templating of this information in the language of API requests or shell commands is an exercise in parsing and templating with a pretty simple logic.

0
votes

In order to copy attributes of your VM you can use the 'Clone' button from your Developer Console->Compute Engine->VM Instance->INSTANCE-NAME page.

If you prefer API or command line, on the clone page at the bottom you can find the REST or command line equivalent.