Creation of an instance template from an existing marketplace lamp VM (Compute Engine)

v14
Bronze 3
Bronze 3

Hi,

So I deployed a lamp VM from the marketplace (https://console.cloud.google.com/marketplace/config/click-to-deploy-images/lamp). I removed the external IP, and I updated (gsutil cp) the default apache index.html located in var/www/html directory. From this existing VM, I created an instance template which I then used to create an instance group. To verify that the template resulted into the creation of the right VMs with the updated index.html file, I ssh into the remaining VM in my instance group. But I only found the default index.html file and none of the files I gsutil cp into my original VM.

How can I create a template that will result into the updated index.html file and other files going into the created vms in my managed instance group?

 

Some of the commands I used

  1. Successfully created the template, didn’t transfer the updated file(s)

 

gcloud compute instance-templates create template1 --source-instance=instance-1 --source-instance-zone=northamerica-northeast1-a

 

  1. Says Device name specified in disk instantiation config not found in source instance

 

gcloud compute instance-templates create template1 --source-instance=instance-1 --source-instance-zone=northamerica-northeast1-a --configure-disk=device-name=instance-1,instantiate-from=source-image,auto-delete=true

 

ERROR: (gcloud.compute.instance-templates.create) Could not fetch resource:

 - Invalid value for field 'resource.sourceInstanceParams.diskConfigs[0].deviceName': 'instance-1'. Device name specified in disk instantiation config not found in source instance: ' instance-1'.

1 REPLY 1

The deviceName attribute for the disk will be calculated, you can either check the cloud console or run this to get the actual device name

gcloud compute instances describe instance-1 --format="yaml(disks[0].deviceName)"

 For example my test VM defaults to "persistent-disk-0".