Search code examples
google-cloud-platformdnswebserver

Is it possible to swap the public IP address between to VM instances in the same GCP project?


I have a Google Cloud Platform project with a server running some web platforms and APIs, to migrate that server to a more modern system, I've set up a new VM instance in the same GCP Project and I was wondering if, instead of changing all DNS records pointing to that IP, is possible to simply swap the public IP from the old VM to the newer one.

I've been looking at some documentation about this but it always starts by releasing the current IP and I'm not sure if, once I've released it, I will be able to use the same IP for the other VM.

Maybe this is too lazy and the correct way to go is to change the DNS records, but the server is holding 6 diferent domains...

If what I'm saying is against some kind of "good practice" please let me know, I'm utterly rookie in this matter.

Thanks in advance for any help that may point me in the right direction.


Solution

  • You must create a static external public address to retain your IP address.

    https://cloud.google.com/compute/docs/ip-addresses/configure-static-external-ip-address

    You can assign this address to a running VM or on VM creation. Removing the address from the VM will not release this address. If you want to turn an ephemeral address into a static one you can do that as well.