Getting started with Google Cloud Platform(GCP)

Google provides the same cloud services as other cloud providers such as Amazon Web Services(AWS) and Microsoft (Azure). It refers it as Google Cloud Platform or GCP. You can easily get started by signing up for free –

List of all products provided in GCP –

Google provides several ways to interact with its services-

1. GCP console (web ui)
GCP console is a web user interface which lets you interact with GCP resources. You can view, create, update and delete cloud resources from this page.

How to create a Linux vm(instance) using the console –

2. Command Line Interface (gcloud cli toolset)
Install gcloud :

The gcloud toolkit is a command line interface tool to interact with GCP resources. Very useful in automating cloud tasks, with its command completion and help pages, it is almost a necessity to familiarize yourself with this tool.

How to create an instance using gcloud cli –

3. Cloud deployment manager
GCP deployment manager allows you to create, delete and update GCP resources in parallel by declaring a set of templates written in jinja2 or python. Templates can be shared with other teams and can be re-used with little modification.

What deployment manager is and how it works –

How to deploy an a GCP instance using deployment manager –

4. APIs
Google provides application programming interface(APIs) to interact with its GCP services. Google recommends using the client libraries over directly calling the RESTful apis.

a. Client libraries

List of client libraries for different programming languages –

How to interact with Google Compute Engine(GCE) using the Python client library –

b. RESTful or raw APIs

API Reference –

Method for creating an instance –

Cloud service providers IP ranges for Amazon Web Services(AWS), Microsoft Azure and Google Cloud Platform(GCP).

Cloud service provides publish the subnet IP ranges through multiple ways. This information is particularly important if you want to setup firewall rules or proxy whitelisting based on IP address range.

1. Amazon Web Services(AWS)

Amazon publishes its current IP address range in JSON format. You can find it here.

This quick and dirty python script dumps the IPv4 address range –

#!/usr/bin/env python

import sys
import requests

    r = requests.get('')
except Exception as e:
    print('Error making https request : {}'.format(e))

if r.status_code == 200:
    for item in r.json().get('prefixes'):

Run script –

$ python  | tee /tmp/aws_ip_range.txt

2. Google Cloud Platform(GCP)

Google makes its cloud IP address range publicly available in DNS as TXT record. The information on how to query DNS to get the IP address range is here.

For GCP, this quick and dirty shell script can pull the IP ranges –


# array to hold list of IP blocks
txt_records=$(dig @${NAME_SERVER} txt +short)
txt_rr_only=$(echo $txt_records | grep -oP 'include:\S+' | sed 's/include://g')
[[ -z ${txt_rr_only} ]] && { echo 'No TXT dns record found.'; exit 1;}
## unpack txt records to get IPv4 ranges
for rr in ${txt_rr_only}; do
  new_ips=$(dig @${NAME_SERVER} $rr txt +short | grep -o -P '(\d+\.){3}\d+/\d+')
  for item in ${new_ips}; do
    # add space separator between ip blocks
    item=" ${item} "

# sort IPs
echo ${ALL_IPS[@]} | sed 's/ /\n/g' | sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4

Run script –

$ ./ | tee gcp_ip_range.txt

3. Microsoft Azure

Microsoft publishes its IP address range in xml format, you can download it from here.

This quick and dirty Python script pulls the IP ranges using BeautifulSoup. Note – this IP range was downloaded on 05/23/2017 – change the date to get the latest data.

#!/usr/bin/env python

import sys
import requests
from bs4 import BeautifulSoup

    r = requests.get('')
except Exception as e:
    print('Error making https request : {}'.format(e))

if r.status_code == 200:
    xml_data = BeautifulSoup(r.text, "lxml")
    ip_range = xml_data.find_all('iprange')
    for ip in ip_range:

Run script –

$ python | tee azure_ip_range.txt