AWS Lambda with MaxMind GeoLite2 IP database

November 3rd, 2017 • 136 Words

The MaxMind GeoLite2 database is basically the standard solution when you need to get the geo information for an IP address. Together with the mmdb-reader NPM package you can easily deploy your own serverless API to AWS Lambda to lookup locations for IP addresses.

Thanks to AWS Lambda the deployed function can be used by other Lambda functions, or via HTTP using Amazon’s API Gateway.


Just clone the serverless-geoip project from GitHub and install the needed dependencies:

$ > git clone
$ > cd serverless-geoip
$ > yarn install

Afterwards, download the GeoLite2 City database and store the file inside the data folder.

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


You can now deploy the project with serverless and send HTTP requests using cURL to lookup the geographical location of an IP address:

$ > yarn deploy


  GET -{ip}

$ > curl

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

First I thought about caching the result in a DynamoDB or Redis, but querying the database is fast enough for now …

View on GitHubSource code is published using the MIT License.
  • CloudFormation Best-Practices

    May 1st, 2019 • 457 Words

    You can find plenty of frameworks and tools to provision your AWS resources. Some of them do a great job for a specific purpose, others are more generic. Nevertheless, I do prefer to use native CloudFormation templates…

  • Makefile Best-Practices

    April 30th, 2019 • 167 Words

    The more projects you work on, the more streamlined your tooling gets. Hopefully. Various services using different languages have different tooling requirements, of course. A sweet Makefile can be the entry to a unified…

  • AppSync GraphQL API with Custom Domain and CloudFormation

    April 7th, 2019 • 165 Words

    With AWS AppSync, it’s easy to run your own serverless GraphQL service API. Thanks to Velocity Mapping Templates, DynamoDB, and AWS Lambda your can aim for an architecture without any maintenance at all. Getting started…

  • Last Update: 2019-12-08T13:15:37.795Z
    Stresemannstraße 132, 22769 Hamburg
    +49 151 54 64 90 55