IPinfo

Public clouds, beside offering IaaS, PaaS solutions they also provide FaaS (Function as a service).
Function as a service (FaaS) is a category of cloud computing services that provides a platform allowing customers to develop, run, and manage application functionalities without the complexity of building and maintaining the infrastructure typically associated with developing and launching an app. Building an application following this model is one way of achieving a “serverless” architecture, and is typically used when building microservices applications.” https://en.wikipedia.org/wiki/Function_as_a_service

Examples of FaaS are AWS Lambda, Google Cloud Functions, and Microsoft Azure Functions.

So I decided to try the Google Cloud Functions and use Python to write one.
Also, I wanted this function to use some API calls. This made me choose to write a function that gathers data about an IP address (your IP as seen when you access the function), like:
ISP, City, Country, AS number. Then using the AS number check to see what upstream AS numbers is this connected to. Also, check if any of the upstream AS have an outage/issue event.
For the gathering info on IP(location, ISP, AS stuff ) I used: https://api.bgpview.io
and for the AS outage/issue event: https://ioda.caida.org

The result i wanted to be a in JSON format and it looks something like this:

curl  https://europe-west3-ip-info-295209.cloudfunctions.net/IP-info
{
    "Your IP is": "x.x.x.x",
    "AS number": 8708,
    "ISP": "RCS-RDS",
    "City": "X city",
    "Country": "RO",
    "Upstream AS": [
        {
            "asn": 3356,
            "name": "LEVEL3",
            "description": "Level 3 Parent, LLC",
            "country_code": "US"
        },
        {
            "asn": 1299,
            "name": "TELIANET",
            "description": "Telia Carrier",
            "country_code": "EU"
        },
        {
            "asn": 3257,
            "name": "GTT-BACKBONE",
            "description": "GTT",
            "country_code": "DE"
        },
        {
            "asn": 2497,
            "name": "IIJ",
            "description": "Internet Initiative Japan Inc.",
            "country_code": "JP"
        },
        {
            "asn": 6461,
            "name": "ZAYO-6461",
            "description": "Zayo Bandwidth",
            "country_code": "US"
        },
        {
            "asn": 49023,
            "name": "INOVO-AS",
            "description": "Str. Mihail Cioranu 4, bl.68, et.1, ap.4,",
            "country_code": "RO"
        },
        {
            "asn": 3549,
            "name": "LVLT-3549",
            "description": "Level 3 Parent, LLC",
            "country_code": "US"
        }
    ],
    "Upstream AS events": [
        [],
        [],
        [],
        [],
        [
            {
                "asn": "6461",
                "Description": "AS6461 (Zayo Bandwidth Inc)",
                "Start time(UTC)": "2020-11-22 13:45:00",
                "Duration": "23:14:21",
                "Status": 0
            }
        ],
        [
            {
                "asn": "49023",
                "Description": "AS49023 (INOVO SOLUTIONS SRL)",
                "Start time(UTC)": "2020-11-22 19:55:00",
                "Duration": "11:45:00",
                "Status": 0
            }
        ],
        []
    ]

Beside gathering all this info about your IP , I also wanted a way to do the same for any other IP (using ?ip=x.x.x.x):

curl  https://europe-west3-ip-info-295209.cloudfunctions.net/IP-info?ip=172.217.4.238

You can find the source code here:
https://github.com/czirakim/Python.IPinfo

And here is how to create a Google Cloud Function:
https://medium.com/google-cloud/deploying-a-python-serverless-function-in-minutes-with-gcp-19dd07e19824

About the author

Mihai is a Senior Network Engineer with more than 15 years of experience