Finding and Removing Unattached GCP External IP Addresses

Unattached external IP Addresses in GCP are a recurring charge on your monthly bill. Here's how you can find and remove them so you can lower your cloud costs.

Patrick Londa
Jul 21, 2022
 min read
Share this post

External IP addresses are a critical component of your Google Cloud infrastructure, enabling public connection to your virtual machines and cloud resources. Just as your  costs scale as your organization adds more Compute Engine VM instances, each external IP address comes with a similarly recurring charge.

For example, static IP addresses that are assigned to a resource, whether in use or not, are billed at a rate of $0.01 per hour. You can read the pricing charges by type here. The bottom line is that if you forget to check and clean up assigned, unused IP addresses, you will face a higher GCP bill on a regular basis.

In this guide, we will show you how to find and clean up these unattached external IP addresses so you can lower your cloud costs.

Blink Automation: Detect Unattached GCP External IP Addresses and Remove Them
GCP + Slack
Try This Automation

Finding Unattached GCP External IP Addresses

To find external IP addresses that are no longer needed, you can get most of the information you need by running this command:

gcloud compute instances list

You’ll see an output that looks like this: 

hulk           us-central1-c   m1-ultramem-160  true                   RUNNING
my-instance    us-central1-c   e2-standard-2         RUNNING

If you have an external IP address that is associated with an instance that has a “Terminated” or “Suspended” status, then that address is considered “in use” and cannot be used by other running resources. You should either look into getting that instance running again or un-assign that external IP address so it can be useful. We’ll explain that process in the next section.

You can get a list of all of your IP addresses with this simple command:

gcloud compute addresses list

You’ll see an output like this one:

address-1      IN_USE
address-2     RESERVED

This view shows all the IP addresses that you would have seen in the “instances list” command (since those had a status of “IN_USE”). This view will also show you IP addresses that have a “RESERVED” status. Reserved means that these IP addresses are not assigned to resources currently. You are still paying for them in the meanwhile.

You can review this list and see if you have more “Reserved” IP addresses than you need. If you are able to un-assign IP addresses after you saw that they were associated with stopped instances, then your number of reserved addresses will increase and you may be able to reduce the overall number of external IP addresses you are paying for by releasing them.

Releasing External IP Addresses

Like finding these addresses, the process of releasing them is this simple gcloud command:

gcloud compute addresses delete <ADDRESS_NAME>

Once released, you will no longer be charged for this IP address. If in the future, you need more external IP addresses than you have in your project, you can just reserve new addresses.

$0.01 cent per hour can seem like such a small charge. Is it really worth it to run through these steps to clean them up? If you have 100 unnecessary IP addresses running per month, that translates to $720/month in wasted spending.

If a team fails to clean up after a project ends, then taking steps like these could save your organization from significant waste.

Automatically Finding Unattached IP Addresses with Blink 

If you want to stay on top of unattached IP addresses, there’s a better way to detect these instead of running manual checks on a regular basis. 

By using a no-code platform like Blink, you can set up simple automations like this one from the Blink library:

Blink Automation: Detect Unattached GCP External IP Addresses and Remove Them Upon Approval
Blink Automation: Detect Unattached GCP External IP Addresses and Remove Them Upon Approval

When this automation runs, it does the following steps:

  1. Gets all unattached GCP external IPs
  2. If any are found, a message is sent to Slack with an option to approve it being released.
  3. If approved, it will then release the unattached IP address.

This is a simple automation, and that makes it easy to customize. You can set it to run on a certain schedule or use conditional logic to retrieve more information.

With over 5K automations in the Blink library, you can get started by importing the most useful ones or by creating new automations from scratch to match your needs.

Get started with Blink today to see how easy automation can be.

Automate your security operations everywhere.

Blink is secure, decentralized, and cloud-native. 
Get modern cloud and security operations today.

Get a Demo