Use MaxMind GeoLite2 database with AWS Lambda
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data Add .gitkeep file to data/ Nov 3, 2017
src Use API Gateway templates Nov 3, 2017
.gitignore Add .gitkeep file to data/ Nov 3, 2017
LICENSE.md Initial commit Nov 3, 2017
README.md Extend README.md Nov 3, 2017
package.json Initial commit Nov 3, 2017
serverless.yml Use API Gateway templates Nov 3, 2017
yarn.lock Initial commit Nov 3, 2017

README.md

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", …