37
votes

How do I rename a Google Compute Engine VM instance?

I created a new LAMP server and I'd like to rename it in the "VM Instances" dashboard.

I've tried renaming the Custom metadata, but that didn't seem to replicate to the dashboard.

10

10 Answers

39
votes

Another way to do this is:

  • snapshot the disk of the existing instance
  • create a new disk from that snapshot
  • create a new instance with that disk and give it the name you would like

It sounds time-consuming, but in reality should take 5 minutes.

41
votes

I tried the solution provided by @Marius I . It works, but I lost my description, my metas, the tags and the permissions I've set on the old instance. I had to copy my metas, had to make sure the zone for the new instance was the same as the original, and had to check that the pricing was the same.

I think, it's best to just create a clone of your original instance, this way don't have to manually copy/set them on the new instance.

  1. As @Marius said, create a snapshot of your disk ( DO NOT skip this part: you may lose all your files/configuration )
  2. Make sure you completed the step 1.
  3. Clone your instance (“Create similar” button)
  4. Name your cloned instance the way you want.
  5. Make sure to select the snapshop of your disk created at #1 ( make sure you select the same typeof disk as well: if your original disk was SSD for example, you have to select if you want the new disk to be SSD too )
  6. Make sure your IPs are set correctly

You're done :)

25
votes

you can't ...! Once VM is created, you can’t change the Instance Name

11
votes

Apart from the hacks above, it's not possible.

Yet, it has been requested on uservoice and has received 593 votes. (as of 2018) Currently, it's the topmost "planned" item.

9
votes

I got lost in the instructions, so I thought I include screenshots because the navigation is confusing. I hope this helps you.

  • Stop your instance
  • Click on the stopped instance name

enter image description here

  • In VM Instance Details, scroll down and click on the disk

enter image description here

  • Click on Create snapshot

enter image description here

  • give it a name like snapshot-1 (or your new instance name)
  • click on Create button

enter image description here

  • click on newly created snapshot

enter image description here

  • Click on Create Instance

enter image description here

  • Give your instance the new name and configure the rest of the VM.

enter image description here

1
votes

When dealing with a robust system, it's necessary to have a way to bring up a system quickly when it goes down. This could be via custom scripts, salt, ansible, etc.

So, if you want to change your instance name, delete the instance, create a new one with the correct name, and run your script again :)

1
votes

To answer your question directly. You cannot edit the VM Instance name.

However, you can create New VM instance using your old disk. To meet the VM instance name that you want.

Kindly see below procedure:

  1. Go to Compute Engine Page
  2. Go to Disk Page
  3. Select the disk of your VM instance that you want to create a snapshot
  4. Click the three dot image same line of your disk
  5. Select +Create Snapshot (You will be go to Create Snapshot page). Kindly name your snapshot (backup)
  6. Just Click Create.

Then once you have created a snapshot for your VM instance disk, you may now proceed on creating your new instance from snapshot pointing to other region which you can consider such: us-central1, us-west1 and us-west2. Please see below procedure:

  1. Go to Snapshot Page
  2. Select snapshot "backup" (You should be on Snapshot details Page)
  3. Click Create Instance (Choose best name for your new VM Instance)
  4. Please select the region best fit for you (us-central1, us-west1 and us-west2) except us-east1.
  5. Lastly, Click Create
1
votes

There's now a "native" way to do this. The feature is currently in Beta and only available in gcloud and API. In gcloud you can run:

$ gcloud beta compute instances set-name CURRENT_NAME —zone=ZONE —new-name=NEW_NAME

Some caveats:

  • You'll need to shut down the VM first
  • The Developer Console UI won't be aware of the rename until you do a browser refresh
0
votes

I am trying to do this 03/2019 and I saw a new option on panel

click Instance link
on top menu you will see "Create Similar"

could work if you need same machine without data. (solved my case) if you need a full copy then you should create a snapshot and clone it.

0
votes

Machine images are now in pre-GA!

This is currently the easiest way to clone an instance without losing your instance configurations, check this comparison table.

Detailed steps:

  1. Go to Compute Engine > Virtual Machines > Machine Images
  2. Click on create Machine Image
  3. Select your current instance under Source VM instance and click create
  4. Once the image becomes ready go to Machine image details and click on create instance
  5. The form will be populated by your existing instance configuration and you'll be able to change them before creating the instance!