Skip to content

Latest commit

 

History

History
60 lines (42 loc) · 1.19 KB

README.md

File metadata and controls

60 lines (42 loc) · 1.19 KB

Serverless GeoIP

Use AWS Lambda and MaxMind GeoLite to query for locations of IP addresses. You can invoke the function or use API Gateway to send an HTTP request with the IP address to lookup.

Install

$ > git clone git@github.com:sbstjn/serverless-geoip.git
$ > cd serverless-geoip
$ > yarn install

Configure

Download the GeoLite2 City database and store the file inside the data folder.

.
└── data
    └── GeoLite2-City.mmdb

Deploy

$ > yarn deploy

…

endpoints:
  GET - https://randomid.execute-api.us-east-1.amazonaws.com/dev/ip/{ip}

Usage

Invoke

$ > sls invoke -f lookup --data '{ "ip": "8.8.8.8" }'

{
    "continent": {
        "code": "NA",
        "geoname_id": 6255149,
        "names": {
            "de": "Nordamerika",
            "en": "North America",
            "es": "Norteamérica",

…
…

HTTP Request

$ > curl https://randomid.execute-api.us-east-1.amazonaws.com/dev/ip/8.8.8.8

{"continent":{"code":"NA","geoname_id":6255149,"names":{"de":"Nordamerika","en":"North America", …