The Wayback Machine - https://web.archive.org/web/20221226072621/https://github.com/tmaiaroto/go-lambda-geoip
Skip to content

tmaiaroto/go-lambda-geoip

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

This is a refactor of an old Go Lambda that creates an API that will return a visitor's geolocation based on IP address. It now uses the Aegis deploy tool and framework, which uses native Go Lambdas now instead of needing a shim.

Prerequisites

The filename will likely be GeoLite2-City.mmdb.

Instructions

Assuming you have AWS credentials configured and you've got the aegis and go-bindata binaries in your path ready to use. You can run the following to retrieve the geoip data set, build, and deploy:

curl -o GeoLite2-City.tar.gz http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz

tar -xvf GeoLite2-City.tar.gz

mv GeoLite2-City_20180327/GeoLite2-City.mmdb GeoLite2-City.mmdb

go-bindata GeoLite2-City.mmdb

aegis deploy

It should build and deploy the Lambda. It may take a little bit due to the size of the database file. It took my 2min 12s to build and deploy (so says my zsh).


You can see the old way we had to use Go in AWS Lambda by looking at the legacy-shim branch and here's the original article.

About

An example using AWS Lambda with Go

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages