简体   繁体   中英

Redshift Connection on Heroku using Django

I am trying to to deploy a Python/Django app on Heroku that needs to execute read-only queries on a Redshift cluster. The primary problem is that the app has a dynamic IP address, but Redshift needs specific IP addresses to be whitelisted .

I would prefer to be able to query the cluster programmatically using the psycopg2 engine or the AWS SDK (Boto). One possibility would be to use a Heroku add-on such as Proximo or QuotaGuard Static to obtain a static IP address, but:

  1. I don't want to route ALL traffic through these add-ons - only the Redshift queries
  2. I don't know how to 'wrap' the database queries through these services

Has anyone else dealt with this problem before? Thanks in advance for any help!

I can connect to Redshift locally, but how do I do so once the app is deployed onto Heroku? I've tried using the Boto3 SDK and a static ip Heroku add-on like QuotaGuard Static or Proximo.

I was able to solve this issue by using the Proximo add on using the steps here:

https://devcenter.heroku.com/articles/proximo#provisioning-the-proximo-add-on

In order to route only the Redshift queries, I used the Proximo mask described here:

https://devcenter.heroku.com/articles/proximo#configuring-the-proximo-wrapper

Edited

Provisioning the Proximo add-on

$ heroku addons:create proximo:development
$ heroku config | grep PROXIMO_URL
$ heroku addons:create proximo:development

Installing the Proximo wrapper

cd ~/myapp
$ curl http://downloads.proximo.io/proximo-stacklet.tgz | tar xz
$ git add bin/proximo vendor/dante
$ git commit -m "add proximo stacklet"

Modify your Procfile to prepend bin/proximo to any command whose connections you would like to forward through your proxy: web: bin/proximo [your existing command]

To use the Proximo mask:

By default, the bin/proximo wrapper will forward all outbound traffic from the wrapped process across your proxy. If you'd like to send only a subset of traffic, you can limit with PROXIMO_MASK:

heroku config:set PROXIMO_MASK="172.18.32.0/24"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM