#15 on Fast Company’s Best Workplaces for Innovators List – Learn more

No More Free External IPs on Google Cloud. How Much Will it Cost You?

1 rkoi5up k0ryunphbopk7q

Recently, Google announced that as of 2020 it will increase the prices of Google Compute Engine VMs that use external IPv4 addresses. Run this script to estimate future costs for your machines.

What used to be a free service will cost a little more now, as Google Cloud decided to charge customers for compute instances that use external IPs as of January 1st, 2020. According to the announcement, the charging will be applied as an additional cost of $0.004 US per hour for an on-demand machine, while preemptable instances will be charged only $0.002 per hour for the use of external IPv4 address. Running a machine for an entire month will result in an extra of $2.92 or $1.46 per month, respectively. It is worth mentioning that unused static IP charges will remain unchanged at $0.01 per hour ($7.30 per month).

How will it affect my account?

As Google Cloud’s largest world-wide partner, DoiT International has set up a short script that will assist cloud users to analyze their current environment to spot VMs running with external IPs. Running the script will allow users to estimate the impact of the upcoming changes to external IPs charging throughout their organization. “We strive to achieve cost efficiency for our customers, but we would also wish to share our knowledge with broader global cloud community,” says the company’s CTO.

Prerequisite to running the script

The script lists all the instances that have external IPs across all the projects of a GCP organization, using the gcloud command-line tool. It uses a service account with the viewer role permissions for the organization level to make the API calls to Google Compute Engine API. You can create such a service account, or have your GCP organization admin create this service account for you, and provide you with the authentication JSON file. If you are authenticated with organization viewer permissions, you can run the script without authenticating with a service account first.

Running the script

curl https://raw.githubusercontent.com/doitintl/list-external-ips/master/ext-ips-analysis.sh | bash

This execution will list all the projects under the organizations to which the caller is authorized to view and iterate through those projects searching for VMs that has an external IP assigned.

You can also execute this script for a single project by passing through the project name like below:

export PROJECT_ID='<enter your project id>'
curl https://raw.githubusercontent.com/doitintl/list-external-ips/master/ext-ips-analysis.sh | bash -s $PROJECT_ID

Output

In the folder that the script is executed from, is a file named projectsIPs.csv, like the one below:

1 kvx2d1ngwgjgzudy7whiqq

Avoiding Unnecessary Charges

Running the script will reveal which VMs are currently running in your organization that may incur additional charges. The first step would be to optimize your projects’ VMs and remove external IPs from VMs that don’t require internet access. However, if these machines do require external accesses, you might want to consider egressing traffic through a NAT gateway (which has its own pricing considerations). There are of course other ways in which you can optimize your VMs to pay only for the external IPs you really need. To discuss that, feel free to contact us through here or leave your thoughts in the comments below.

Liked this story? Follow the DoiT International blog to get more cloud cost-optimization stories.

Subscribe to updates, news and more.