Unable to update fields of an external static IP address

Problem

A user has no option to remove/change the fields of an existing static external IP address. This applies also to changing the description field of a static IP.

Environment

  • VPC
  • External Static IP.

Solution

The only method to update the fields of a static IP is to recreate and reallocate the same static external IP.

There is no guarantee that the same static IP will be reallocated if it was released while not in use.

Follow these steps in order to have the best chance of getting the same static external IP allocated:

  1. Create a new VM in the same project and any zone in the same region and assign it the external IP that needs to be reallocated.

    $ gcloud compute instances create [VM_NAME] \
             --zone [ZONE] \
             --machine-type [MACHINE_TYPE] \
             --image-project [IMAGE_PROJECT] \
             --image-family [IMAGE_FAMILY] \
             --subnet [SUBNET] \
             --address [EXTERNAL_STATIC_IP_ADDRESS_TO_BE_REALLOCATED]
  2. If billing is a concern, you can stop the VM at this point.

    $ gcloud compute instances stop [VM_NAME] --zone [ZONE]
  3. Verify that the static address now lists the newly created VM as a user.

    $ gcloud compute addresses describe [EXTERNAL_STATIC_IP_NAME] --region [REGION]
  4. The output should be similar to the following:

  • address: [EXTERNAL_STATIC_IP_ADDRESS]
  • addressType: EXTERNAL
  • description: [DESCRIPTION]
  • status: IN_USE
  • users: link
  1. Delete the static address.

    $ gcloud compute addresses delete [EXTERNAL_STATIC_IP_NAME] --region [REGION] -q
    
  2. Create a new static address specifying the same external static IP address along with the desired new updates. This should work because the IP is still used by the project.

    $ gcloud compute addresses create [EXTERNAL_STATIC_IP_NAME] \
             --region [REGION] \
             --description “[NEW_DESCRIPTION]” \
             --addresses [THE_SAME_EXTERNAL_STATIC_IP_ADDRESS]
  3. Delete the VM created in the first step.

    $ gcloud compute instances delete [VM_NAME] --zone [ZONE] -q
  4. Verify that the static address now has the status RESERVED instead of IN_USE.

    $ gcloud compute addresses describe [EXTERNAL_STATIC_IP_NAME] --region [REGION].

Cause

The Compute Engine Addresses API has no methods to update existing addresses. Therefore, updating addresses information isn't possible and the only way around that is to delete and recreate the address in question with the new properties in place.