4

I have an existing Cloud Compute Engine instance that was mistakenly assigned the wrong static internal IP.

I cannot figure out a way to modify the internal IP address to the correct value using the Console or other means. I have tried reserving a new static internal IP, which is easy enough, but there is no way to assign it to an existing resource.

I am talking about Google Console -- not the OS. I know how to change the value in the OS itself.

When I view the resource directly on Google Console and try to edit nic0 in the Google Console, it does not give me any option to modify the existing static IP to a different address. It just says "static ip: 10.x.x.x".

I could easily enough just nuke this resource and make a new one, except for the policy of not being able to re-use the resource name. And I want this specific resource name, so killing it or cloning it is not an option. I just need to modify it's internal IP!

Edit to add: To be clear, I have no problem stopping the instance. I just don't want to destroy it due to reserved naming policy preventing re-use of resource names. I need to modify an in-place resource to a new internal static reserved IP.

ctrlbrk
  • 1,174
  • 2
  • 17
  • 27
  • https://cloud.google.com/compute/docs/ip-addresses/reserve-static-internal-ip-address – John Hanley Jul 08 '19 at 22:01
  • @JohnHanley that is where I started of course. Nothing there has helped me. Please be more specific as to which section will solve my problem? This clearly says "You cannot change the internal IP address of an existing resource. For example, you cannot assign a new static internal IP address to a running VM instance. You can, however, promote the ephemeral internal IP address of a resource to a static internal IP so that the address remains reserved even after the resource is deleted." --- but my assigned IP is not Ephemeral, it is static. So how do I change an existing static IP to anoth? – ctrlbrk Jul 08 '19 at 23:50
  • To be clear, I have no problem stopping the instance. I just don't want to destroy it due to reserved naming policy preventing re-use of resource names. I need to modify an in-place resource to a new internal static reserved IP. – ctrlbrk Jul 08 '19 at 23:52

2 Answers2

8

As of 2021 the accepted answer is incorrect. You can move the instance with the wrong internal static IP address to a different network and then move it back to the original network: This bizarelly allows you to reassign the internal IP.

Fleuri
  • 318
  • 5
  • 11
6

Once you have a VM instance created, you cant change internal IP. It is mentioned explicitly.

The only option you have is to create a new VM with a static IP. You can make a snapshot of the disk from the VM you are using, then create a new VM from that disk marking --private-network-ip.

Create a disk from a snapshot:

gcloud compute --project "your-project" disks create "instance-x" \
--size "100" 
--zone "europe-west1-c" \
--source-snapshot "snapshot-x" \
--type "pd-standard" 

Use the disk to create a new VM with a predefined internal IP:

gcloud compute --project=your-project instances create instance-x \
--zone=europe-west1-c \
--private-network-ip=your-ip \
--disk=name=instance-x,device-name=instance-x,mode=rw,boot=yes,auto-delete=yes
Ivan
  • 302
  • 1
  • 5
  • I marked you as answered even though the truth is, there is no answer due to google's policy of not allowing re-use of resource name, and/or not allowing the changing of an internal IP for an existing resource. – ctrlbrk Jul 09 '19 at 17:40
  • I recommend you check out @Fleuri answer below. Because you actually can do it, if you're willing to take an extra step. – deltamind106 Feb 28 '23 at 20:17