Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use DynamoDB through Heroku?

I am interested in using DynamoDB through Heroku. Will this work securely and how would I set up communication? I am using Java but help in any language would be fine.

Sources of info I've found thus far:

  • This question seems to imply it is possible without explaining how.
  • This question explains how Heroku can connect to elasticache (not DynamoDB) but goes on to explain that it is insecure as any Heroku application can connect to the elasticache server. I would like to make sure that however I connect to DynamoDB is, in fact, secure.
  • This video explaining how to connect to DynamoDB via Ruby in Heroku is no longer available.
  • This video keeps talking about how they're going to use DynamoDB from Heroku, and then the next presenter admits that he couldn't get something else to work and never went on to talk about using DynamoDB in Heroku.
like image 549
Daniel Centore Avatar asked Dec 19 '22 16:12

Daniel Centore


1 Answers

Yes. You can indeed use DynamoDB with Heroku. I use it for a large application that handles about 15 billion requests per month.

Here's what you'll want to do:

  1. Set your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables in your Heroku app. When you sign up for AWS, you'll have to generate these if you have none already. Once you get them, store them in Heroku as environment variables.

  2. Install a DynamoDB library in your language / framework of choice.

  3. When you initialize your AWS library for DynamoDB, it will ask for 2 things: your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, so you can supply those from your environment variables.

The way this works in terms of security is like so:

  • Heroku runs on AWS in the us-east region.
  • If you create a DynamoDB instance in us-east, it will be in the same 'network' as your Heroku app.
  • When your Heroku app connects to DynamoDB, it will do so securely over SSL, using your AWS API keys as a username/password to connect.
  • When your Heroku app makes requests to DynamoDB, it will be very fast, as both your Heroku app and your DynamoDB instance are very close together physically.

Hope this helps =)

like image 168
rdegges Avatar answered Jan 05 '23 17:01

rdegges