Skip to content

Simple Python handler for AWS Lambda to determine a user's geo-location based on their IP.

License

Notifications You must be signed in to change notification settings

marianzange/aws-lambda-geoip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IP based geo-location with AWS Lambda

This is a simple Python handler for AWS Lambda to determine a user's geo-location based on their IP. To map IP's to countries (or cities if you choose), we use MaxMind's GeoLite2 database which can be downloaded here: https://dev.maxmind.com/geoip/geoip2/geolite2/

Exposing through Amazon API Gateway

There are many ways to configure API Gateway to fit your needs. The minimum things you need to do to expose this lambda function are the following:

  1. Create a new resource and add a GET method
  2. To the Body Mapping Templates in the Integration Request add the following:
{
  "requesterIp" : "$context.identity.sourceIp"
}
  1. Congrats! This is the minimal setup to request your lambda function through API gateway.

About

Simple Python handler for AWS Lambda to determine a user's geo-location based on their IP.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages