Question

I'm trying to figure out how to install and use GeoIP libraries on AWS (Elastic Beanstalk). As far I know EB has an "ephemeral filesystem", but I could store the CeoCity binary in S3… but what about MaxMind C libraries? Has anyone configured EB to use MaxMind's api?

(My stack is based on Python/Django)

Was it helpful?

Solution 2

I believe you have two options to handle situations where new EC2 instances are being created automatically for you:

Amazon issues a notice about using custom AMI:s:

"After you are running on your own custom AMI, you will no longer receive any 
automated updates to the operating system, software stack, or the AWS Elastic 
Beanstalk host manager."

Personally, I've stuck to using configuration files. Takes a bit of tinkering, but once I got it working it operates pretty well.

Good luck!

OTHER TIPS

I don't know why you'd bother customising an AMI when a simple .ebextensions script would do the job with the added advantage of downloading a fresh Maxmind DB with every deploy. Note that my example script is hardcoded to the latest GeoIP client code as of today so you might want to upgrade this every now and then. But I doubt there'll be huge changes to the client code so it'll always work. This script is for the PHP API and free GeoLite2 databases, it's easy to change out for Python client code.

files:
  "/usr/local/bin/geoip2.phar" :
    mode: "000644"
    owner: root
    group: root
    source: https://github.com/maxmind/GeoIP2-php/releases/download/v2.1.1/geoip2.phar

  "/usr/local/share/GeoIP/GeoLite2-City.mmdb.gz" :
    mode: "000644"
    owner: root
    group: root
    source: http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz

  "/usr/local/share/GeoIP/GeoLite2-Country.mmdb.gz" :
    mode: "000644"
    owner: root
    group: root
    source: http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz

commands:
  gunzip_maxmind_city:
    command: gunzip -f GeoLite2-City.mmdb.gz
    cwd: /usr/local/share/GeoIP
  gunzip_maxmind_country:
    command: gunzip -f GeoLite2-Country.mmdb.gz
    cwd: /usr/local/share/GeoIP

An alternate approach would be to use AWS EB to attach a snapshot of an EBS volume.

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-as-launchconfig-blockdev-mapping.html

Whenever an environment is created with this setting, the nivolved instances will get it attached. from this point, you can, say, take it over with .ebextensions.

(It also allows you to map ephemeral volumes on instances supporting eg m1.small)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top