You can unassign a static external IP address by deleting the instance or deleting the access config attached to the instance that is using the address. Unassigning an IP address removes it from the resource but keeps the IP address reserved to your project.
To delete an instance's access config and unassign a static external IP address, follow these steps:
Get the name of the access config to delete. To get the name, perform a gcloud compute instances describe request:
gcloud compute instances describe [INSTANCE_NAME]
where [INSTANCE_NAME] is the name of the instance.
The access config appears in the following format:
- kind: compute#accessConfig
Delete the access config.
Use the instances delete-access-config sub-command:
gcloud compute instances delete-access-config [INSTANCE_NAME] \
Check that your static external IP address is now available and marked as RESERVED instead of IN_USE.
gcloud compute addresses list
NAME REGION ADDRESS STATUS
example-address [REGION] 22.214.171.124 RESERVED
example-address-new [REGION] 126.96.36.199 RESERVED
Now that your static external IP address is available, you can choose to assign it to another instance.