https://github.com/sbstjn/serverless-geoip
Use MaxMind GeoLite2 database with AWS Lambda
https://github.com/sbstjn/serverless-geoip
geoip geolib geolite2 lambda maxwind serverless
Last synced: about 1 year ago
JSON representation
Use MaxMind GeoLite2 database with AWS Lambda
- Host: GitHub
- URL: https://github.com/sbstjn/serverless-geoip
- Owner: sbstjn
- License: mit
- Created: 2017-11-02T19:02:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-11T04:15:02.000Z (about 8 years ago)
- Last Synced: 2025-04-01T16:24:23.195Z (about 1 year ago)
- Topics: geoip, geolib, geolite2, lambda, maxwind, serverless
- Language: JavaScript
- Size: 22.5 KB
- Stars: 45
- Watchers: 4
- Forks: 15
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Serverless GeoIP
Use AWS Lambda and [MaxMind GeoLite](http://dev.maxmind.com/geoip/geoip2/geolite2/) 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
```bash
$ > git clone git@github.com:sbstjn/serverless-geoip.git
$ > cd serverless-geoip
$ > yarn install
```
## Configure
Download the [GeoLite2 City](http://dev.maxmind.com/geoip/geoip2/geolite2/) database and store the file inside the `data` folder.
```bash
.
└── data
└── GeoLite2-City.mmdb
```
## Deploy
```bash
$ > yarn deploy
…
endpoints:
GET - https://randomid.execute-api.us-east-1.amazonaws.com/dev/ip/{ip}
```
## Usage
### Invoke
```bash
$ > 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
```bash
$ > 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", …
```