Amazon Elastic Beanstalk上的MaxMind GeoIP库和数据库

dav*_*ode 3 amazon-s3 amazon-web-services geoip maxmind amazon-elastic-beanstalk

我正在试图弄清楚如何在AWS上安装和使用GeoIP库(Elastic Beanstalk).据我所知,EB有一个"短暂的文件系统",但我可以在S3中存储CeoCity二进制文件......但是MaxMind C库呢?有没有人配置EB使用MaxMind的API?

(我的堆栈基于Python/Django)

geo*_*sey 6

我不知道为什么当一个简单的.ebextensions脚本能够完成这项工作时,你会厌烦自定义AMI,并且每次部署时都会下载一个新的Maxmind DB.请注意,我的示例脚本已经硬编码到今天的最新GeoIP客户端代码,因此您可能希望不时地升级它.但是我怀疑客户端代码会有很大的变化,所以它总会有效.此脚本适用于PHP API和免费的GeoLite2数据库,可以轻松更改Python客户端代码.

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
Run Code Online (Sandbox Code Playgroud)